李天标 il y a 5 ans
Parent
commit
f8fdcb41ed

+ 188 - 15
app-api/src/main/java/com/hboxs/control/api/order/OrderController.java

@@ -45,6 +45,8 @@ public class OrderController extends BaseController {
     private ProportionService proportionService;
     @Resource(name = "mchServiceImpl")
     private MchService mchService;
+    @Resource(name = "promoCodeServiceImpl")
+    private PromoCodeService promoCodeService;
     /**
      * 请求在线支付
      *
@@ -602,25 +604,143 @@ public class OrderController extends BaseController {
         kindData.put("sn" , sn);
         kindData.put("productName" , productName);
 
-
-//        new Thread(){
-//            public void run(){
-//                try {
-//                    Thread.sleep(5000);
-//                    System.out.println("123");
-//                } catch (InterruptedException e) { }
-//            }
-//        }.start();
         PushUtils.push(equipmentService.findByClientId(client).getGtClientId(), "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
 
-//        Timer timer=new Timer();//实例化Timer类
-//        timer.schedule(new TimerTask(client,kindData){
-//            public void run(){
-//                PushUtils.push(equipmentService.findByClientId(client).getGtClientId(), "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
-//                System.out.println("退出");
-//                this.cancel();}},20000);
+    }
+
+    @RequestMapping(value = "/send2", method = RequestMethod.GET)
+    @ResponseBody
+    public Object send2(String sn,Double price){
+        // 订单号
+
+        //价格
+
+        //生成优惠码的个数
+        double num = price/0.02;
+        int number = (int) num;
+        Order order = orderService.findBySn(sn);
+        Admin admin = adminService.find(order.getAdminId());
+        if(order.getStatus()!=Order.Status.unpay){
+            return "success";
+        }
+
+        if(JoinpayConstant.r6_Status_100.equals("100")){
+
+            // 已支付
+            order.setStatus(Order.Status.pay);
+
+            // 支付平台产生的流水号
+
+            // 格式:YYYY-MM-DD HH:mm:ss
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date payDate = new Date();
+            order.setPayDate(payDate);
+            orderService.update(order);
+
+            JSONObject kindData = new JSONObject();
+            kindData.put("sn" , order.getSn());
+            kindData.put("productName" , order.getProductName());
+            List<String> codes =new ArrayList<>();
+            for(int i=0;i<number;i++){
+                String code = orderService.initSn(order.getEquipmentId());
+                StringBuffer str = new StringBuffer();
+                str.append(code.substring(0,4)).append(code.substring(code.length()-4,code.length()));
+                codes.add(str.toString());
+            }
+            for(String code : codes){
+                PromoCode promoCode = new PromoCode();
+                promoCode.setCode(Long.parseLong(code));
+                promoCode.setAdminId(String.valueOf(order.getAdminId()));
+                promoCode.setIsUse("0");
+                promoCode.setCreateDate(new Date());
+                promoCode.setModifyDate(null);
+                promoCode.setUserName(admin.getUsername());
+                promoCodeService.save(promoCode);
+            }
+
+//            PushUtils.push(equipmentService.findByClientId(order.getClientId()).getGtClientId(), "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
+
+            return "支付成功";
+        }
+
+        return "success";
 
     }
+
+    /**
+     * 优惠码支付成功回调
+     *
+     * @return
+     */
+    @RequestMapping(value = "/promoCodeNotify", method = RequestMethod.GET)
+    @ResponseBody
+    public Object promoCoderefund(HttpServletRequest request) {
+
+        String r6_Status = request.getParameter("r6_Status");
+
+        // 订单号
+        String sn = request.getParameter("r2_OrderNo");
+        //价格
+        String price = request.getParameter("r3_Amount");
+        //生成优惠码的个数
+        double num = Long.valueOf(price)/0.02;
+        int number = (int) num;
+        Order order = orderService.findBySn(sn);
+        if(order.getStatus()!=Order.Status.unpay){
+            return "success";
+        }
+
+        if(JoinpayConstant.r6_Status_100.equals(r6_Status)){
+
+            // 已支付
+            order.setStatus(Order.Status.pay);
+
+            // 支付平台产生的流水号
+            String r7_TrxNo = request.getParameter("r7_TrxNo");
+            order.setTrxNo(r7_TrxNo);
+
+            // 格式:YYYY-MM-DD HH:mm:ss
+            String ra_PayTime = request.getParameter("ra_PayTime");
+
+            try {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                Date payDate = sdf.parse(URLDecoder.decode(ra_PayTime, "UTF-8"));
+                order.setPayDate(payDate);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            } catch (UnsupportedEncodingException e) {
+
+                e.printStackTrace();
+            }
+
+            orderService.update(order);
+            Admin admin = adminService.find(order.getAdminId());
+            JSONObject kindData = new JSONObject();
+            kindData.put("sn" , order.getSn());
+            kindData.put("productName" , order.getProductName());
+            List<String> codes =new ArrayList<>();
+            for(int i=0;i<number;i++){
+                String code = orderService.initSn(order.getEquipmentId());
+                StringBuffer str = new StringBuffer();
+                str.append(code.substring(0,4)).append(code.substring(code.length()-4,code.length()));
+                codes.add(str.toString());
+            }
+            for(String code : codes){
+                PromoCode promoCode = new PromoCode();
+                promoCode.setCode(Long.parseLong(code));
+                promoCode.setAdminId(String.valueOf(order.getAdminId()));
+                promoCode.setIsUse("0");
+                promoCode.setCreateDate(new Date());
+                promoCode.setUserName(admin.getUsername());
+                promoCodeService.save(promoCode);
+            }
+
+            return "支付成功";
+        }
+
+        return "success";
+    }
     /**
      * 支付成功回调
      *
@@ -694,6 +814,59 @@ public class OrderController extends BaseController {
     }
 
     /**
+     * 优惠码做糖
+     *
+     * @param
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/promoCodeDo", method = RequestMethod.GET)
+    @ResponseBody
+    public JsonMessage promoCodeDo(String code ,String  clientId) {
+        Equipment equipment = equipmentService.findByClientId(clientId);
+        PromoCode promoCode = promoCodeService.findByCode(Long.valueOf(code));
+        if(promoCode==null){
+            //不存在
+            return JsonMessage.success("1");
+        }
+        if(promoCode.getIsUse().equals("1")){
+            //被使用
+            return JsonMessage.success("2");
+        }
+        if(String.valueOf(equipment.getAdminId()).equals(promoCode.getAdminId())){
+            promoCode.setIsUse("1");
+            promoCode.setUseBy(equipment.getName());
+            SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String time= sdf.format( new Date());
+            promoCode.setUseDate(time);
+            promoCodeService.update(promoCode);
+            //可以做糖
+            return JsonMessage.success("0");
+        }else {
+            //不是本机
+            return JsonMessage.success("3");
+        }
+    }
+
+    /**
+     * 做糖失败,优惠码重回原始状态
+     *
+     * @param
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/promoCodeUpdate", method = RequestMethod.GET)
+    @ResponseBody
+    public JsonMessage promoCodeUpdate(String code ) {
+        PromoCode promoCode = promoCodeService.findByCode(Long.valueOf(code));
+            promoCode.setIsUse("0");
+            promoCode.setUseBy(null);
+            promoCode.setUseDate(null);
+            promoCodeService.update(promoCode);
+            return JsonMessage.success("0");
+    }
+
+    /**
      * 请求在线退款
      * @param sn
      * @param clientId

+ 384 - 0
app-backend-web/src/main/java/com/hboxs/control/admin/PromoCodeController.java

@@ -0,0 +1,384 @@
+/*
+ *
+ *
+ *
+ */
+package com.hboxs.control.admin;
+
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.hboxs.common.*;
+import com.hboxs.common.utils.CookieUtils;
+import com.hboxs.common.utils.PushUtils;
+import com.hboxs.entity.*;
+import com.hboxs.entity.Order;
+import com.hboxs.excel.OrderTarget;
+import com.hboxs.excel.PromoCodeTarget;
+import com.hboxs.joinpay.entity.Mch;
+import com.hboxs.service.*;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.authc.AuthenticationToken;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * Controller - 代理商
+ */
+@Controller("adminPromoCodeController")
+@RequestMapping("/asl-admin/promoCode")
+public class PromoCodeController extends BaseController {
+
+    @Resource(name = "adminServiceImpl")
+    private AdminService adminService;
+    @Resource(name = "promoCodeServiceImpl")
+    private PromoCodeService promoCodeService;
+    @Resource(name = "roleServiceImpl")
+    private RoleService roleService;
+    @Resource(name = "globalConfigServiceImpl")
+    private GlobalConfigService globalConfigService;
+    @Resource(name = "mchServiceImpl")
+    private MchService mchService;
+    @Resource(name = "equipmentServiceImpl")
+    private EquipmentService equipmentService;
+    @Resource(name = "tradeServiceImpl")
+    private TradeService tradeService;
+    @Resource(name = "productServiceImpl")
+    private ProductService productService;
+    @Resource(name = "orderServiceImpl")
+    private OrderService orderService;
+    @Resource(name = "proportionServiceImpl")
+    private ProportionService proportionService;
+
+    /**
+     * 列表
+     */
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    public String agencyList(Long code,String isUse,Pageable pageable, ModelMap model) {
+        String a = "";
+        if (code != null) {
+            pageable.getFilters().add(Filter.eq("code", code));
+        }
+        if (isUse != null) {
+            pageable.getFilters().add(Filter.eq("isUse", isUse));
+        }
+        //        pageable.getFilters().add(Filter.eq("type", Admin.Type.agency));
+//        pageable.getFilters().add(Filter.eq("isAdmined" , false));
+        model.addAttribute("isUse", isUse);
+        model.addAttribute("code", code);
+        model.addAttribute("page", promoCodeService.findPage(pageable));
+        model.addAttribute("currentAdmin", adminService.getCurrent());
+        return "/admin/promoCode/list";
+    }
+
+    /**
+     * 添加
+     */
+    @RequestMapping(value = "/add", method = RequestMethod.GET)
+    public String add(ModelMap model) {
+
+        return "/admin/promoCode/add";
+    }
+
+    @RequestMapping(value = "/edit", method = RequestMethod.GET)
+    public String edit(ModelMap model) {
+
+        return "/admin/promoCode/edit";
+    }
+    /**
+     * 请求在线支付
+     *
+     * @param
+     * @param
+     * @param
+     * @return
+     */
+    @RequestMapping(value = "/img", method = RequestMethod.GET)
+    public String img(int number, String frpCode ,Pageable pageable, ModelMap model) {
+        Admin admin = adminService.getCurrent();
+        List<Equipment> equipmentList = equipmentService.findByAdminId(admin.getId());
+        Equipment equipment = equipmentList.get(0);
+        Long equipmentId = equipment.getId();
+        Proportion proportion = proportionService.getUniqueness(equipment.getAdminId());
+        Proportion.Type type = proportion.getType();
+        Order.Type orderType = null;
+        Long agencyId = admin.getAgencyId();
+        Long merchantId = admin.getMerchantId();
+        Long personageId = admin.getPersonageId();
+        switch (type) {
+            case agency:
+                orderType = Order.Type.agency;
+                break;
+            case merchant:
+                orderType = Order.Type.merchant;
+                break;
+            case personage:
+                orderType = Order.Type.personage;
+                break;
+        }
+        String sn = orderService.initSn(equipmentId);
+        String orderNo = sn;
+        String productName = "优惠码";
+        BigDecimal price = BigDecimal.valueOf(0.02*number);
+        BigDecimal cutPrice = price.multiply(new BigDecimal(100)).divide(new BigDecimal(100));
+        BigDecimal amount = cutPrice;
+        String productDesc = "";
+        String commonParameter = "";
+        String returnUrl = null;
+        String notifyUrl = JoinpayConstant.Notify_Url_PromoCode;
+        String isShowPic = "1";
+        String openId = null;
+        String authCode = null;
+        String appid = null;
+        String transactionModel = null;
+        String tradeMerchantNo = null;
+        String buyerId = null;
+        String isAlt = "0";
+        String altType = null;
+        String altUrl = null;
+        BigDecimal marketingAmount = null;
+
+//        com.hboxs.entity.Order order = new com.hboxs.entity.Order(sn, product.getId(), productName, price, equipment.getClientId(), equipmentId,
+//                orderType, admin.getId(), agencyId, merchantId, personageId,
+//                frpCode, altInfo.toString(), adminProportion, agencyProportion, merchantProportion, personageProportion, Order.Status.unpay);
+        Order order1 = new Order();
+        order1.setSn(sn);
+        order1.setType(orderType);
+        order1.setAgencyId(agencyId);
+        order1.setMerchantId(merchantId);
+        order1.setPersonageId(personageId);
+        order1.setAdminId(admin.getId());
+        order1.setProductName(productName);
+        order1.setPrice(price);
+        order1.setEquipmentId(equipmentId);
+        order1.setClientId(equipment.getClientId());
+        order1.setStatus(Order.Status.unpay);
+        order1.setFrp_code(frpCode);
+        orderService.create(order1);
+
+        JSONArray altInfo = new JSONArray();
+        String result = null;
+        try {
+            result = tradeService.uniPay(
+
+                    orderNo, amount, productName, productDesc,
+                    commonParameter, returnUrl, notifyUrl, frpCode,
+                    isShowPic, openId, authCode, appid, transactionModel, tradeMerchantNo,
+                    buyerId, isAlt, altType, altInfo, altUrl, marketingAmount
+            );
+
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+//            return JsonMessage.error("申请支付失败");
+            return "申请支付失败";
+        }
+
+        JSONObject resultJson = JSONObject.parseObject(result);
+        // 汇聚支付支付申请返回支付二维码图片
+        String rd_Pic = resultJson.getString("rd_Pic");
+
+        if (resultJson == null || StringUtils.isBlank(rd_Pic)) {
+            return "找不到支付图片";
+        }
+//        ModelMap model = new ModelMap();
+        model.addAttribute("image", rd_Pic);
+        model.addAttribute("price", price);
+        return "/admin/promoCode/img";
+    }
+    /**
+     * 支付成功回调
+     *
+     * @return
+     */
+    @RequestMapping(value = "/promoCodeNotify", method = RequestMethod.GET)
+    @ResponseBody
+    public Object refund(HttpServletRequest request) {
+
+        String r6_Status = request.getParameter("r6_Status");
+
+        // 订单号
+        String sn = request.getParameter("r2_OrderNo");
+        //价格
+        String price = request.getParameter("r3_Amount");
+        //生成优惠码的个数
+        double num = Long.valueOf(price)/0.02;
+        int number = (int) num;
+        Order order = orderService.findBySn(sn);
+        if(order.getStatus()!=Order.Status.unpay){
+            return "success";
+        }
+
+        if(JoinpayConstant.r6_Status_100.equals(r6_Status)){
+
+            // 已支付
+            order.setStatus(Order.Status.pay);
+
+            // 支付平台产生的流水号
+            String r7_TrxNo = request.getParameter("r7_TrxNo");
+            order.setTrxNo(r7_TrxNo);
+
+            // 格式:YYYY-MM-DD HH:mm:ss
+            String ra_PayTime = request.getParameter("ra_PayTime");
+
+            try {
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                Date payDate = sdf.parse(URLDecoder.decode(ra_PayTime, "UTF-8"));
+                order.setPayDate(payDate);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            } catch (UnsupportedEncodingException e) {
+
+                e.printStackTrace();
+            }
+
+            orderService.update(order);
+            Admin admin = adminService.find(order.getAdminId());
+            JSONObject kindData = new JSONObject();
+            kindData.put("sn" , order.getSn());
+            kindData.put("productName" , order.getProductName());
+            List<String> codes =new ArrayList<>();
+            for(int i=0;i<number;i++){
+                String code = orderService.initSn(order.getEquipmentId());
+                StringBuffer str = new StringBuffer();
+                str.append(code.substring(0,4)).append(code.substring(code.length()-4,code.length()));
+                codes.add(str.toString());
+            }
+            for(String code : codes){
+                PromoCode promoCode = new PromoCode();
+                promoCode.setCode(Long.parseLong(code));
+                promoCode.setAdminId(String.valueOf(order.getAdminId()));
+                promoCode.setIsUse("0");
+                promoCode.setCreateDate(new Date());
+                promoCode.setUserName(admin.getUsername());
+                promoCodeService.save(promoCode);
+            }
+
+//            PushUtils.push(equipmentService.findByClientId(order.getClientId()).getGtClientId(), "支付成功", "您的订单支付成功", PushUtils.buildJson("pay_success", kindData.toString()).toString());
+
+            return "支付成功";
+        }
+
+        return "success";
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    public
+    @ResponseBody
+    Message delete(Long[] ids) {
+        if (ids.length >= adminService.count()) {
+            return Message.error("admin.common.deleteAllNotAllowed");
+        }
+        adminService.delete(ids);
+        return SUCCESS_MESSAGE;
+    }
+
+    @RequestMapping(value = "/export")
+    public Object export(HttpServletResponse response, Long[] ids, String date) {
+
+        Admin admin = adminService.getCurrent();
+
+        List<Admin> admins = adminService.findAllLowerAdmin(admin.getId());
+        Long[] lowerIds = null;
+        if (admins == null) {
+            lowerIds = new Long[]{};
+        } else {
+            lowerIds = new Long[admins.size()];
+            for (int i = 0; i < admins.size(); i++) {
+                lowerIds[i] = admins.get(i).getId();
+            }
+        }
+
+        List<Filter> filters = new ArrayList<>();
+
+        switch (admin.getType()) {
+            case admin:
+                break;
+            case agency:
+                filters.add(Filter.in("adminId", lowerIds));
+                break;
+            case merchant:
+                filters.add(Filter.in("adminId", lowerIds));
+                break;
+            case personage:
+                filters.add(Filter.in("adminId", lowerIds));
+                break;
+        }
+
+
+        try {
+            if (StringUtils.isNotBlank(date)) {
+                String[] datestring = date.split(" - ");
+                Date startDate = new SimpleDateFormat("yyyy-MM-dd").parse(datestring[0]);
+                Date endDate = new SimpleDateFormat("yyyy-MM-dd").parse(datestring[1]);
+                filters.add(Filter.geDate("createDate", startDate));
+                filters.add(Filter.leDate("createDate", DateUtils.addDays(endDate, 1)));
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+            return JsonMessage.success("导出错误");
+        }
+
+        //List<Order> list = orderService.findList(ids);
+//        List<Order> list = orderService.findList(null, filters, null);
+//        List<OrderTarget> orderTargetList = orderService.findById(admin, list);
+        List<PromoCode> list = promoCodeService.findList(null, filters, null);
+        List<PromoCodeTarget> promoCodeTargets = promoCodeService.findById(list);
+
+
+
+        ExportParams exportParams = new ExportParams("优惠码记录", "sheet1");
+        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, PromoCodeTarget.class, promoCodeTargets);
+
+        if (workbook != null) {
+            OutputStream os = null;
+            try {
+                os = response.getOutputStream();
+                SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
+                response.setContentType("application/vnd.ms-excel;charset=utf-8");
+                response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("订单记录数据导出" + format.format(new Date()) + ".xls", "UTF-8"));
+                workbook.write(os);
+                return JsonMessage.success("导出成功");
+            } catch (Exception e) {
+                e.printStackTrace();
+                return JsonMessage.success("导出错误");
+            } finally {
+                try {
+                    os.close();
+                    workbook.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return JsonMessage.success("导出错误");
+    }
+
+}

+ 6 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/common/main.ftl

@@ -231,6 +231,12 @@
                                 class="iconfont icon-shebei"></i> 设备管理</a>
                     </dd>
                 [/@shiro.hasPermission]
+                [@shiro.hasPermission name="admin:promoCode"]
+                    <dd>
+                        <a href="javascript:void(0)" data-url="../promoCode/list.htm"  data-id="admin:promoCode"><i
+                                    class="iconfont icon-shebei"></i> 优惠码</a>
+                    </dd>
+                [/@shiro.hasPermission]
             [#--  [@shiro.hasPermission name="admin:trusteeship"]
                   <dd>
                       <a href="javascript:void(0)"

+ 82 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/promoCode/add.ftl

@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title>代理商添加</title>
+<link href="/resources/admin/layui/css/layui.css" rel="stylesheet" type="text/css" />
+<link href="/resources/admin/iconfont/iconfont.css" rel="stylesheet" type="text/css"/>
+<link href="/resources/admin/css/common.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="/resources/admin/js/jquery.js"></script>
+<script type="text/javascript" src="/resources/admin/js/jquery.tools.js"></script>
+<script type="text/javascript" src="/resources/admin/js/jquery.validate.js"></script>
+<script type="text/javascript" src="/resources/admin/layui/layui.js"></script>
+<script type="text/javascript" src="/resources/admin/js/common.js"></script>
+<script type="text/javascript" src="/resources/admin/js/input.js"></script>
+<script type="text/javascript" src="/resources/admin/js/jquery.lSelect.js"></script>
+<script type="text/javascript">
+$().ready(function() {
+
+	var $inputForm = $("#inputForm");
+	[@flash_message /]
+    var $areaId = $("#areaId");
+    $areaId.lSelect({
+        url: "/asl-admin/common/area.htm"
+    });
+});
+</script>
+</head>
+<body>
+	<div class="path">
+        首页 &raquo; 优惠码申请
+	</div>
+	<form id="inputForm" action="img.htm" method="get">
+		<table class="input">
+			<tr>
+				当前优惠码价格为:0.5元/个
+			</tr>
+			<tr>
+				<th>
+					&nbsp;你要购买的优惠码个数:
+				</th>
+				<td>
+					<input type="text" name="number" id="number" class="text" maxlength="200"  value="10" />
+					&nbsp &nbsp支付方式
+					<label><input id="frpCode" name="frpCode" type="radio" value="WEIXIN_NATIVE" checked/>微信 </label>
+					<label><input id="frpCode" name="frpCode" type="radio" value="ALIPAY_NATIVE" />支付宝 </label>
+					[#--					&nbsp &nbsp <input type="button" class="button" id="buy" value="购买" />--]
+[#--					<a href="buy.htm" class="" id="buy">--]
+[#--						<i class="iconfont icon-anonymous-iconfont1">&nbsp;</i>购买--]
+[#--					</a>--]
+						<input id="equUpdate" type="submit" class="button" value="购买"/>
+
+				</td>
+			</tr>
+
+			<tr>
+				<td>
+
+					<input type="button" class="button" value="返回" onclick="location.href='list.htm'"/>
+				</td>
+			</tr>
+		</table>
+	</form>
+</body>
+<script>
+	// 购买优惠码
+	// $('#buy').click(function(){
+	// 	var num=document.getElementById("number").value;
+	// 	var frpCode=document.getElementById("frpCode").value;
+	// 	$.ajax({
+	// 		url:"/asl-admin/promoCode/buy.htm",
+	// 		type:"post",
+	// 		data:{
+	// 			"number":num,
+	// 			"frpCode":frpCode,
+	// 		},
+	// 		success: function(data){
+	// 			layer.msg('');
+	// 		}
+	// 	})
+	// });
+</script>
+</html>

+ 82 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/promoCode/edit.ftl

@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+<title>代理商添加</title>
+<link href="/resources/admin/layui/css/layui.css" rel="stylesheet" type="text/css" />
+<link href="/resources/admin/iconfont/iconfont.css" rel="stylesheet" type="text/css"/>
+<link href="/resources/admin/css/common.css" rel="stylesheet" type="text/css"/>
+<script type="text/javascript" src="/resources/admin/js/jquery.js"></script>
+<script type="text/javascript" src="/resources/admin/js/jquery.tools.js"></script>
+<script type="text/javascript" src="/resources/admin/js/jquery.validate.js"></script>
+<script type="text/javascript" src="/resources/admin/layui/layui.js"></script>
+<script type="text/javascript" src="/resources/admin/js/common.js"></script>
+<script type="text/javascript" src="/resources/admin/js/input.js"></script>
+<script type="text/javascript" src="/resources/admin/js/jquery.lSelect.js"></script>
+<script type="text/javascript">
+$().ready(function() {
+
+	var $inputForm = $("#inputForm");
+	[@flash_message /]
+    var $areaId = $("#areaId");
+    $areaId.lSelect({
+        url: "/asl-admin/common/area.htm"
+    });
+});
+</script>
+</head>
+<body>
+	<div class="path">
+        首页 &raquo; 优惠码申请
+	</div>
+	<form id="inputForm" action="img.htm" method="get">
+		<table class="input">
+			<tr>
+				当前优惠码价格为:0.5元/个1111111111
+			</tr>
+			<tr>
+				<th>
+					&nbsp;你要购买的优惠码个数:
+				</th>
+				<td>
+					<input type="text" name="number" id="number" class="text" maxlength="200"  value="10" />
+					&nbsp &nbsp支付方式
+					<label><input id="frpCode" name="frpCode" type="radio" value="WEIXIN_NATIVE" checked/>微信 </label>
+					<label><input id="frpCode" name="frpCode" type="radio" value="ALIPAY_NATIVE" />支付宝 </label>
+					[#--					&nbsp &nbsp <input type="button" class="button" id="buy" value="购买" />--]
+[#--					<a href="buy.htm" class="" id="buy">--]
+[#--						<i class="iconfont icon-anonymous-iconfont1">&nbsp;</i>购买--]
+[#--					</a>--]
+						<input id="equUpdate" type="submit" class="button" value="购买"/>
+
+				</td>
+			</tr>
+
+			<tr>
+				<td>
+
+					<input type="button" class="button" value="返回" onclick="location.href='list.htm'"/>
+				</td>
+			</tr>
+		</table>
+	</form>
+</body>
+<script>
+	// 购买优惠码
+	// $('#buy').click(function(){
+	// 	var num=document.getElementById("number").value;
+	// 	var frpCode=document.getElementById("frpCode").value;
+	// 	$.ajax({
+	// 		url:"/asl-admin/promoCode/buy.htm",
+	// 		type:"post",
+	// 		data:{
+	// 			"number":num,
+	// 			"frpCode":frpCode,
+	// 		},
+	// 		success: function(data){
+	// 			layer.msg('');
+	// 		}
+	// 	})
+	// });
+</script>
+</html>

+ 58 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/promoCode/img.ftl

@@ -0,0 +1,58 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <title>优惠码列表</title>
+    <link href="/resources/admin/layui/css/layui.css" rel="stylesheet" type="text/css"/>
+    <link href="/resources/admin/iconfont/iconfont.css" rel="stylesheet" type="text/css"/>
+    <link href="/resources/admin/css/common.css" rel="stylesheet" type="text/css"/>
+    <script type="text/javascript" src="/resources/admin/js/jquery.js"></script>
+    <script type="text/javascript" src="/resources/admin/layui/layui.js"></script>
+    <script type="text/javascript" src="/resources/admin/js/common.js"></script>
+    <script type="text/javascript" src="/resources/admin/js/list.js"></script>
+    <script type="text/javascript"
+            src="https://webapi.amap.com/maps?v=1.4.10&key=fa88b622064b112e8caefeb05f40b790"></script>
+    <script type="text/javascript">
+        $().ready(function () {
+
+	[@flash_message /]
+
+        });
+    </script>
+</head>
+<body>
+<div class="path ">
+    首页 &raquo; 优惠码支付
+</div>
+
+
+<form id="listForm" action="img.htm" method="get" class="">
+    <div class="bar buttonWrap">
+
+        </div>
+
+    </div>
+    <table class="input">
+        <tr>
+            <th>
+                &nbsp;您需要支付:${price}元
+            </th>
+            <td>
+                <img src="${image}">
+            </td>
+        </tr>
+[#--        ${rd_Pic}--]
+
+        <tr>
+            <td>
+                <input type="button" class="button" value="返回" onclick="location.href='list.htm'" />
+            </td>
+        </tr>
+    </table>
+
+</form>
+
+</body>
+
+</html>

+ 341 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/promoCode/list.ftl

@@ -0,0 +1,341 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
+    <title>优惠码列表</title>
+    <link href="/resources/admin/layui/css/layui.css" rel="stylesheet" type="text/css"/>
+    <link href="/resources/admin/iconfont/iconfont.css" rel="stylesheet" type="text/css"/>
+    <link href="/resources/admin/css/common.css" rel="stylesheet" type="text/css"/>
+    <script type="text/javascript" src="/resources/admin/js/jquery.js"></script>
+    <script type="text/javascript" src="/resources/admin/layui/layui.js"></script>
+    <script type="text/javascript" src="/resources/admin/js/common.js"></script>
+    <script type="text/javascript" src="/resources/admin/js/list.js"></script>
+    <script type="text/javascript"
+            src="https://webapi.amap.com/maps?v=1.4.10&key=fa88b622064b112e8caefeb05f40b790"></script>
+    <script type="text/javascript">
+        $().ready(function() {
+
+            [@flash_message /]
+
+            layui.use('form', function(){
+                var form = layui.form;
+            });
+
+            layui.use('laydate', function(){
+                var laydate = layui.laydate;
+
+                //日期时间范围
+                laydate.render({
+                    elem: '#beginEndDate'
+                    ,type: 'datetime'
+                    ,range: true
+                    ,theme: '#d6bf3b'
+                });
+
+            });
+
+        });
+    </script>
+    <style type="text/css">
+        .editNo {
+            color: rgba(230, 0, 0, 0.93) !important;
+            cursor: pointer;
+            margin-left: 5px;
+        }
+
+        .freshNo {
+            color: #00B83F !important;
+            cursor: pointer;
+            margin-left: 5px;
+        }
+
+        .l {
+            width: 15px !important;
+        }
+
+    </style>
+
+</head>
+<body>
+<div class="path ">
+    首页 &raquo; 优惠码列表 <span>(总共${page.total}行)</span>
+</div>
+
+
+<form id="listForm" action="list.htm" method="get" class="">
+    <div class="bar buttonWrap">
+    <a href="add.htm" class="iconButton" id="addButton">
+        <i class="iconfont icon-anonymous-iconfont1">&nbsp;</i>申请优惠码
+    </a>
+        <div class="buttonWrap">
+        [#if admin.type == "admin"]
+        <a href="javascript:" id="deleteButton" class="iconButton disabled">
+            <i class="iconfont icon-shequshanchu">&nbsp;</i>删除
+        </a>
+        [/#if]
+            <a href="javascript:" id="refreshButton" class="iconButton">
+                <i class="iconfont icon-shuaxin1">&nbsp;</i>刷新
+            </a>
+            <div class="menuWrap">
+                <a href="javascript:" id="pageSizeSelect" class="button">
+                    每页行数<span class="arrow">&nbsp;</span>
+                </a>
+                <div class="popupMenu">
+                    <ul id="pageSizeOption">
+                        <li>
+                            <a href="javascript:"[#if page.pageSize == 10] class="current"[/#if] val="10">10</a>
+                        </li>
+                        <li>
+                            <a href="javascript:"[#if page.pageSize == 20] class="current"[/#if] val="20">20</a>
+                        </li>
+                        <li>
+                            <a href="javascript:"[#if page.pageSize == 50] class="current"[/#if] val="50">50</a>
+                        </li>
+                        <li>
+                            <a href="javascript:"[#if page.pageSize == 100] class="current"[/#if] val="100">100</a>
+                        </li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+        <div class="search-bar">
+            优惠码 <input type="text" name="code" class="text" value="${code}"/>
+            使用状态
+            <select name="isUse">
+                <option value="" >全部</option>
+                <option value="0" [#if isUse=="0"] selected[/#if]>未使用</option>
+                <option value="1" [#if isUse=="1"] selected[/#if]>已使用</option>
+            </select>
+            <button class="layui-btn layui-btn-normal layui-btn-xs">筛选</button>
+        </div>
+
+    </div>
+    <div style="margin-left:10px;padding:5px;border: 1px solid" class="search-bar">
+        日期 <input id="exportDate" style="height: 24px;width: 150px" type="text" name="exportDate"
+                  placeholder=" - "/>
+
+        <button id="export" class="layui-btn layui-btn-normal layui-btn-xs">导出Excel</button>
+    </div>
+    <table id="listTable" class="list">
+        <tr>
+            <th class="check">
+                <input type="checkbox" id="selectAll"/>
+            </th>
+            <th style="width: 250px">
+                <a href="javascript:" class="sort" name="code">优惠码</a>
+            </th>
+            <th>
+                <a href="javascript:" class="sort" name="userName">拥有者</a>
+            </th>
+            <th>
+                <a href="javascript:" class="sort" name="createDate">创建时间</a>
+            </th>
+            <th>
+                <a href="javascript:" class="sort" name="isUse">是否使用</a>
+            </th>
+            <th>
+                <a href="javascript:" class="sort" name="useDate">使用时间</a>
+            </th>
+            <th>
+                <a href="javascript:" class="sort" name="useBy">使用机器</a>
+            </th>
+        </tr>
+			[#list page.content as promoCode]
+				<tr>
+                    <td>
+                        <input type="checkbox" name="ids" value="${promoCode.id}"/>
+                    </td>
+
+                    <td>
+                        ${promoCode.code}
+                    </td>
+                    <td>
+                        ${promoCode.userName}
+                    </td>
+                    <td>
+                        ${promoCode.createDate?string("yyyy-MM-dd HH:mm:ss")}
+                    </td>
+[#--                    <td>--]
+[#--                        ${promoCode.isUse}--]
+[#--                    </td>--]
+                    [#if promoCode.isUse==0]
+                    <td>
+                        <span class="green">未使用</span>
+                    </td>
+                    [#else]
+                        <td>
+                            <span class="red">使用</span>
+                        </td>
+                    [/#if]
+                    <td>
+                        ${promoCode.useDate}
+                    </td>
+                    <td>
+                        ${promoCode.useBy}
+                    </td>
+                </tr>
+            [/#list]
+    </table>
+		[@pagination pageNumber = page.pageNumber totalPages = page.totalPages]
+            [#include "/admin/include/pagination.ftl"]
+        [/@pagination]
+</form>
+
+</body>
+<script type="text/javascript">
+    $().ready(function () {
+        layui.use('laydate', function () {
+            var laydate = layui.laydate;
+            laydate.render({
+                elem: '#exportDate'
+                , range: true
+                , theme: '#d6bf3b'
+            });
+        });
+
+        $('#export').click(function () {
+            var date = $('#exportDate').val();
+            window.location.href = "export.htm?" + "date=" + date;
+            return false;
+        });
+
+    });
+</script>
+[#--<script>--]
+[#--    var h = '<div id="container" style="width: 1200px;height: 650px"></div>';--]
+[#--    $('.location').click(function () {--]
+
+[#--        var longitude = $(this).attr('data-longitude');--]
+[#--        var latitude = $(this).attr('data-latitude');--]
+[#--        if (longitude == '' || latitude == '') {--]
+[#--            layer.msg('获取不到经纬度');--]
+[#--            return;--]
+[#--        }--]
+
+[#--        var index = layer.open({--]
+[#--            content: h,--]
+[#--            shade: false,--]
+[#--            area: [longitude, latitude],--]
+[#--        });--]
+
+[#--        var map = new AMap.Map('container', {--]
+[#--            center: [longitude, latitude],--]
+[#--            zoom: 15--]
+[#--        });--]
+
+[#--        // 创建一个 Marker 实例:--]
+[#--        var marker = new AMap.Marker({--]
+[#--            position: new AMap.LngLat(longitude, latitude)   // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]--]
+[#--        });--]
+
+[#--        // 将创建的点标记添加到已有的地图实例:--]
+[#--        map.add(marker);--]
+
+[#--    });--]
+
+[#--    $('.editNo').click(function () {--]
+[#--        var id = $(this).attr('data-id');--]
+[#--        var name = $(this).attr('data-name');--]
+
+[#--        if (name == '') {--]
+[#--            layer.msg('请完善设备信息再进行设备号推送');--]
+[#--            return;--]
+[#--        }--]
+[#--        layui.use('layer', function () {--]
+[#--            var layer = layui.layer;--]
+
+[#--            //例子2--]
+[#--            layer.prompt({--]
+[#--                formType: 2,--]
+[#--                value: '',--]
+[#--                title: '正在修改 "' + name + '" 设备号',--]
+[#--                area: ['300px', '40px'] //自定义文本域宽高--]
+[#--            }, function (value, index, elem) {--]
+[#--                layer.close(index);--]
+
+[#--                $.ajax({--]
+[#--                    url: 'editNo.htm',--]
+[#--                    type: "GET",--]
+[#--                    data: {no: value, id: id},--]
+[#--                    dataType: "json",--]
+[#--                    cache: false,--]
+[#--                    beforeSend: function () {--]
+[#--                        mask = layer.load(1, {shade: [0.4, '#333333']});--]
+[#--                    },--]
+[#--                    success: function (data) {--]
+[#--                        layer.close(mask);--]
+[#--                        if (data.code == 0) {--]
+[#--                            layer.msg(data.data);--]
+[#--                        } else {--]
+[#--                            layer.msg(data.errmsg);--]
+[#--                        }--]
+[#--                    },--]
+[#--                    error: function () {--]
+[#--                        layer.close(mask);--]
+[#--                    }--]
+[#--                });--]
+[#--            });--]
+[#--        });--]
+[#--    });--]
+
+
+[#--    $('.freshNo').click(function () {--]
+[#--        var id = $(this).attr('data-id');--]
+[#--        var t = $(this);--]
+[#--        $.ajax({--]
+[#--            url: 'getNo.htm',--]
+[#--            type: "GET",--]
+[#--            data: {id: id},--]
+[#--            dataType: "json",--]
+[#--            cache: false,--]
+[#--            beforeSend: function () {--]
+[#--                t.html('<img class="l" src="/resources/admin/images/loading.gif" />')--]
+[#--            },--]
+[#--            success: function (data) {--]
+[#--                setTimeout(t.html('刷新'), 1000);--]
+[#--                if (data.code == 0) {--]
+[#--                    t.parent('td').find('b').html(data.data)--]
+[#--                } else {--]
+[#--                    layer.msg(data.errmsg);--]
+[#--                }--]
+[#--            },--]
+[#--            error: function () {--]
+[#--                t.html('刷新')--]
+[#--            }--]
+[#--        });--]
+[#--    });--]
+
+[#--</script>--]
+[#--<script>--]
+[#--    $(".status").click(function () {--]
+[#--        var id = $(this).attr('data-id');--]
+[#--        var code = $(this).attr('data-status');--]
+[#--        var url = $(this).attr('data-url');--]
+[#--        layer.confirm('确定执行此操作?', {icon: 3, title: '提示'}, function (index) {--]
+[#--            $.ajax({--]
+[#--                url: url,--]
+[#--                data: {--]
+[#--                    code: code,--]
+[#--                    id: id--]
+[#--                },--]
+[#--                type: "POST",--]
+[#--                dataType: "json",--]
+[#--                cache: false,--]
+[#--                success: function (data) {--]
+[#--                    if (data.type == "success") {--]
+
+[#--                        location.reload();--]
+[#--                    } else {--]
+[#--                        layer.msg("执行失败");--]
+[#--                    }--]
+[#--                }--]
+[#--            });--]
+
+[#--            layer.close(index);--]
+[#--        });--]
+[#--    });--]
+[#--</script>--]
+
+
+</html>

+ 12 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/role/add.ftl

@@ -132,6 +132,9 @@ $().ready(function() {
                         <label>
 							<input type="checkbox" name="authorities" value="admin:equipment" />设备管理
 					    </label>
+						<label>
+							<input type="checkbox" name="authorities" value="admin:promoCode" />优惠码
+					    </label>
                         <label>
 							<input type="checkbox" name="authorities" value="admin:trusteeship"/>设备托管管理
 					    </label>
@@ -217,6 +220,9 @@ $().ready(function() {
                         <label>
 							<input type="checkbox" name="authorities" value="admin:equipment" />设备管理
 					    </label>
+						<label>
+							<input type="checkbox" name="authorities" value="admin:promoCode" />优惠码
+					    </label>
 					</span>
                 </td>
             </tr>
@@ -276,6 +282,9 @@ $().ready(function() {
                         <label>
 							<input type="checkbox" name="authorities" value="admin:equipment" />设备管理
 					    </label>
+						<label>
+							<input type="checkbox" name="authorities" value="admin:promoCode" />优惠码
+					    </label>
 					</span>
                 </td>
             </tr>
@@ -306,6 +315,9 @@ $().ready(function() {
                         <label>
 							<input type="checkbox" name="authorities" value="admin:equipment" />设备管理
 					    </label>
+						<label>
+							<input type="checkbox" name="authorities" value="admin:promoCode" />优惠码
+					    </label>
 					</span>
                 </td>
             </tr>

+ 20 - 0
app-backend-web/src/main/webapp/WEB-INF/template/admin/role/edit.ftl

@@ -153,6 +153,11 @@
                                        value="admin:equipment" [#if role.authorities?seq_contains("admin:equipment")]
                                        checked="checked"[/#if] />设备管理
                             </label>
+                            <label>
+                                <input type="checkbox" name="authorities"
+                                       value="admin:promoCode" [#if role.authorities?seq_contains("admin:promoCode")]
+                                    checked="checked"[/#if] />优惠码
+                            </label>
                         <label>
 							<input type="checkbox" name="authorities"
                                    value="admin:trusteeship"           [#if role.authorities?seq_contains("admin:trusteeship")]
@@ -268,6 +273,11 @@
                                        value="admin:equipment" [#if role.authorities?seq_contains("admin:equipment")]
                                        checked="checked"[/#if] />设备管理
                             </label>
+                            <label>
+                                <input type="checkbox" name="authorities"
+                                       value="admin:promoCode" [#if role.authorities?seq_contains("admin:promoCode")]
+                                    checked="checked"[/#if] />优惠码
+                            </label>
                         </span>
                     </td>
                 </tr>
@@ -339,6 +349,11 @@
                                        value="admin:equipment" [#if role.authorities?seq_contains("admin:equipment")]
                                        checked="checked"[/#if] />设备管理
                             </label>
+                            <label>
+                                <input type="checkbox" name="authorities"
+                                       value="admin:promoCode" [#if role.authorities?seq_contains("admin:promoCode")]
+                                    checked="checked"[/#if] />优惠码
+                            </label>
                         </span>
                     </td>
                 </tr>
@@ -374,6 +389,11 @@
                                        value="admin:equipment" [#if role.authorities?seq_contains("admin:equipment")]
                                        checked="checked"[/#if] />设备管理
                             </label>
+                            <label>
+                                <input type="checkbox" name="authorities"
+                                       value="admin:promoCode" [#if role.authorities?seq_contains("admin:promoCode")]
+                                    checked="checked"[/#if] />优惠码
+                            </label>
                         </span>
                     </td>
                 </tr>

+ 2 - 0
app-common/src/main/java/com/hboxs/common/JoinpayConstant.java

@@ -42,6 +42,8 @@ public class JoinpayConstant {
      */
     public final static String Notify_Url = "http://app.sunzee.com.cn/api/order/notify.htm";
 
+    public final static String Notify_Url_PromoCode = "http://app.sunzee.com.cn/api/order/promoCodeNotify.htm";
+
     public final static Map<String,String> Result_status = new HashMap<>();
     /**
      *  退款成功回调

+ 16 - 0
app-dao/src/main/java/com/hboxs/dao/PromoCodeDao.java

@@ -0,0 +1,16 @@
+/*
+ *
+ *  ADDao
+ *
+ */
+package com.hboxs.dao;
+
+import com.hboxs.entity.PromoCode;
+
+/**
+ * Dao - 广告管理
+ */
+public interface PromoCodeDao extends BaseDao<PromoCode, Long> {
+
+    PromoCode findByCode(Long code);
+}

+ 34 - 0
app-dao/src/main/java/com/hboxs/dao/impl/PromoCodeDaoImpl.java

@@ -0,0 +1,34 @@
+/*
+ *
+ *  ADDaoImpl
+ *
+ */
+package com.hboxs.dao.impl;
+
+import com.hboxs.dao.PromoCodeDao;
+import com.hboxs.entity.PromoCode;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.FlushModeType;
+import javax.persistence.NoResultException;
+
+/**
+ * Dao - 优惠码
+ */
+@Repository("promoCodeDaoImpl")
+public class PromoCodeDaoImpl extends BaseDaoImpl<PromoCode, Long> implements PromoCodeDao {
+
+    @Override
+    public PromoCode findByCode(Long code) {
+        if (code==null){
+            return null;
+        }
+        try {
+            String promoCode="select promoCode from PromoCode promoCode where promoCode.code= :code";
+
+            return entityManager.createQuery(promoCode, PromoCode.class).setFlushMode(FlushModeType.COMMIT).setParameter("code",code).getSingleResult();
+        } catch (NoResultException e) {
+            return null;
+        }
+    }
+}

+ 99 - 0
app-entity/src/main/java/com/hboxs/entity/PromoCode.java

@@ -0,0 +1,99 @@
+package com.hboxs.entity;
+
+
+import javax.persistence.Entity;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.Table;
+import java.util.Date;
+@Entity
+//@Entity(name = "t_promo_code")
+@Table(name = "t_promo_code")
+@SequenceGenerator(name = "sequenceGenerator", sequenceName = "t_promo_code_sequence")
+public class PromoCode extends BaseEntity{
+//  @Id
+//  private Long id;
+
+  private String adminId;
+
+//  private Date createDate;
+
+  private String useDate;
+
+  private long code;
+
+  private String isUse;
+
+  private String useBy;
+
+  private String userName;
+
+  public String getAdminId() {
+    return adminId;
+  }
+
+  public void setAdminId(String adminId) {
+    this.adminId = adminId;
+  }
+
+  public String getUseDate() {
+    return useDate;
+  }
+
+  public void setUseDate(String useDate) {
+    this.useDate = useDate;
+  }
+
+  public String getUserName() {
+    return userName;
+  }
+
+  public void setUserName(String userName) {
+    this.userName = userName;
+  }
+//  @Override
+//  public Date getCreateDate() {
+//    return createDate;
+//  }
+//
+//  @Override
+//  public void setCreateDate(Date createDate) {
+//    this.createDate = createDate;
+//  }
+//
+//  @Override
+//  public Date getModifyDate() {
+//    return modifyDate;
+//  }
+//
+//  @Override
+//  public void setModifyDate(Date modifyDate) {
+//    this.modifyDate = modifyDate;
+//  }
+
+  public long getCode() {
+    return code;
+  }
+
+  public void setCode(long code) {
+    this.code = code;
+  }
+
+
+  public String getIsUse() {
+    return isUse;
+  }
+
+  public void setIsUse(String isUse) {
+    this.isUse = isUse;
+  }
+
+
+  public String getUseBy() {
+    return useBy;
+  }
+
+  public void setUseBy(String useBy) {
+    this.useBy = useBy;
+  }
+
+}

+ 111 - 0
app-entity/src/main/java/com/hboxs/excel/PromoCodeTarget.java

@@ -0,0 +1,111 @@
+package com.hboxs.excel;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+//订单导出
+public class PromoCodeTarget {
+
+    /**
+     * 优惠码
+     */
+    @Excel(name = "优惠码", width = 20.0D)
+    private Long code;
+
+    /**
+     * 商家id
+     */
+    @Excel(name = "商家id", width = 20.0D)
+    private String adminId;
+
+
+    /**
+     * 所属商家
+     */
+    @Excel(name = "所属商家", width = 20.0D)
+    private String userName;
+
+    /**
+     * 添加时间
+     */
+    @Excel(name = "添加时间", width = 20.0D)
+    private Date createDate;
+
+
+
+    /**
+     * 状态
+     */
+    @Excel(name = "状态", width = 20.0D)
+    private String isUse;
+
+    /**
+     * 使用时间
+     */
+    @Excel(name = "使用时间", width = 20.0D)
+    private String useDate;
+
+    /**
+     * 使用机器
+     */
+    @Excel(name = "使用机器", width = 20.0D)
+    private String useBy;
+
+    public Long getCode() {
+        return code;
+    }
+
+    public void setCode(Long code) {
+        this.code = code;
+    }
+
+    public String getAdminId() {
+        return adminId;
+    }
+
+    public void setAdminId(String adminId) {
+        this.adminId = adminId;
+    }
+
+    public String getUserName() {
+        return userName;
+    }
+
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+
+    public String getIsUse() {
+        return isUse;
+    }
+
+    public void setIsUse(String isUse) {
+        this.isUse = isUse;
+    }
+
+    public String getUseDate() {
+        return useDate;
+    }
+
+    public void setUseDate(String useDate) {
+        this.useDate = useDate;
+    }
+
+    public String getUseBy() {
+        return useBy;
+    }
+
+    public void setUseBy(String useBy) {
+        this.useBy = useBy;
+    }
+}

+ 21 - 0
app-service/src/main/java/com/hboxs/service/PromoCodeService.java

@@ -0,0 +1,21 @@
+/*
+ *
+ * ADService
+ *
+ */
+package com.hboxs.service;
+
+import com.hboxs.entity.PromoCode;
+import com.hboxs.excel.PromoCodeTarget;
+
+import java.util.List;
+
+/**
+ * Service -
+ */
+public interface PromoCodeService extends BaseService<PromoCode, Long> {
+
+    PromoCode findByCode(Long code);
+
+    List<PromoCodeTarget> findById(List<PromoCode> list);
+}

+ 59 - 0
app-service/src/main/java/com/hboxs/service/impl/PromoCodeServiceImpl.java

@@ -0,0 +1,59 @@
+/*
+ *
+ *  ADServiceImpl
+ *
+ */
+package com.hboxs.service.impl;
+
+import com.hboxs.dao.PromoCodeDao;
+import com.hboxs.entity.PromoCode;
+import com.hboxs.excel.PromoCodeTarget;
+import com.hboxs.service.PromoCodeService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Service - 广告管理
+ */
+@Service("promoCodeServiceImpl")
+public class PromoCodeServiceImpl extends BaseServiceImpl<PromoCode, Long> implements PromoCodeService {
+
+    @Resource(name = "promoCodeDaoImpl")
+    private PromoCodeDao promoCodeDao;
+
+    @Resource(name = "promoCodeDaoImpl")
+    public void setBaseDao(PromoCodeDao promoCodeDao) {
+        super.setBaseDao(promoCodeDao);
+    }
+
+
+    @Override
+    public PromoCode findByCode(Long code) {
+        return promoCodeDao.findByCode(code);
+    }
+
+    @Override
+    public List<PromoCodeTarget> findById(List<PromoCode> list) {
+        List<PromoCodeTarget> promoCodeTargets = new ArrayList<>();
+        for(PromoCode promoCode : list){
+            PromoCodeTarget promoCodeTarget = new PromoCodeTarget();
+            promoCodeTarget.setCode(promoCode.getCode());
+            promoCodeTarget.setAdminId(promoCode.getAdminId());
+            promoCodeTarget.setCreateDate(promoCode.getCreateDate());
+            if(promoCode.getIsUse().equals("0")){
+                promoCodeTarget.setIsUse("未使用");
+            }else {
+                promoCodeTarget.setIsUse("已使用");
+            }
+            promoCodeTarget.setUseBy(promoCode.getUseBy());
+            promoCodeTarget.setUseDate(promoCode.getUseDate());
+            promoCodeTarget.setUserName(promoCode.getUserName());
+            promoCodeTargets.add(promoCodeTarget);
+        }
+
+        return promoCodeTargets;
+    }
+}