1
0
Pārlūkot izejas kodu

优惠券使用

zcb 4 gadi atpakaļ
vecāks
revīzija
7b133202fe

+ 14 - 16
kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java

@@ -73,6 +73,8 @@ public class OrderController {
     private ShippingService shippingService;
 
     private volatile Integer code = 1;
+    @Autowired
+    private UserService userService;
 
     /**
      * 列表
@@ -1054,22 +1056,18 @@ public class OrderController {
         return R.ok().put("resultObj", result);
     }
 
-//    @RequestMapping("/getIdCardInfo")
-//    public R getIdCardInfo() throws IOException {
-//
-//        Map map = new HashMap();
-//        String ssl = OkHttpUtils.post(map,"http://127.0.0.1:8000/idcard/read", "SSL");
-//        Pattern pattern = Pattern.compile("(\\\\u(\\p{XDigit}{4}))");
-//        Matcher matcher = pattern.matcher(ssl);
-//        char ch;
-//        while (matcher.find()) {
-//            ch = (char) Integer.parseInt(matcher.group(2), 16);
-//            ssl = ssl.replace(matcher.group(1), ch + "");
-//        }
-//
-//        return R.ok().put("info",ssl);
-//
-//    }
+    @RequestMapping("/queryIDCardInfo/{mobile}")
+    public R queryIDCardInfo(@PathVariable("mobile")String mobile) throws IOException {
+
+        UserEntity userEntity = userService.queryByMobile(mobile);
+        if (userEntity == null) {
+            return R.error("该手机号未找到对应信息");
+        }
+
+
+        return R.ok().put("userEntity",userEntity);
+
+    }
 
 
     @RequestMapping("/purchaseSalesInStockDetail")

+ 2 - 0
kmall-admin/src/main/java/com/kmall/admin/service/UserService.java

@@ -76,4 +76,6 @@ public interface UserService {
      * @return
      */
     Map checkFaceTimeByUserId(Long userId);
+
+    UserEntity queryByMobile(String mobile);
 }

+ 7 - 3
kmall-admin/src/main/java/com/kmall/admin/service/impl/GoodsServiceImpl.java

@@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -331,7 +332,7 @@ public class GoodsServiceImpl implements GoodsService {
 //        builder.put("freightId", "运费模版");
         builder.put("primaryPicUrl", "商品主图");
         builder.put("listPicUrl", "商品列表图");
-        builder.put("goodsDesc", "商品描述");
+//        builder.put("goodsDesc", "商品描述");
         builder.put("isOnSale", "上架");
         builder.put("isHot", "热销");
 
@@ -380,7 +381,7 @@ public class GoodsServiceImpl implements GoodsService {
         // 商品轮播图
         List<GoodsGalleryEntity> galleryEntityList = goods.getGoodsImgList();
         if (galleryEntityList == null || galleryEntityList.size() <= 0) {
-            throw new RRException("至少保留一张商品轮播图!");
+//            throw new RRException("至少保留一张商品轮播图!");
         }
 
         List<GoodsEntity> prodbarGoodsList = goodsDao.queryObjectByProdBarcode(goods.getProdBarcode(),goods.getMerchSn(),goods.getId());
@@ -1118,8 +1119,11 @@ public class GoodsServiceImpl implements GoodsService {
             return null;
         }
         goods.setDiscountedPrice(new BigDecimal(0));
-        goods.setActualPaymentAmount(goods.getRetailPrice());
         String goodsRate = goods.getGoodsRate();
+        BigDecimal tax = goods.getRetailPrice().multiply(new BigDecimal(goodsRate)).setScale(2, RoundingMode.HALF_UP);
+        goods.setGoodstaxes(tax.toString());
+        goods.setActualPaymentAmount(goods.getRetailPrice().add(tax).setScale(2,RoundingMode.HALF_UP));
+
         Map<String,Object> skuActivitiesMap = new HashMap<>();
 
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

+ 47 - 26
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -1698,6 +1698,9 @@ public class OrderServiceImpl implements OrderService {
             Integer storeId = user.getStoreId();
 
             List<GoodsEntity> goodsEntities = new ArrayList<>();
+
+            BigDecimal totalTax = new BigDecimal(0);
+
             // 检查库存和更新库存
             for (LinkedHashMap goodsDto : goodsList) {
                 //
@@ -1737,26 +1740,26 @@ public class OrderServiceImpl implements OrderService {
                         return resultObj;
                     } else {
                         // 判断销售价是否低于底线价
-                        if(productInfo.getBottomLinePrice() != null){
-                            BigDecimal bottomLinePrice = new BigDecimal(productInfo.getBottomLinePrice());
-                            if (goodsEntity.getStoreRetailPrice().compareTo(bottomLinePrice) <= -1) {
-                                LOGGER.error("销售价格小于底线价格");
-
-                                // 记录该信息,到价格过低日志表中,这里没有活动id
-                                Mall2LowPriceWarningEntity lowPriceWarningEntity = new Mall2LowPriceWarningEntity();
-                                lowPriceWarningEntity.setSalePrice(goodsEntity.getStoreRetailPrice());
-                                lowPriceWarningEntity.setWarningPrice(bottomLinePrice);
-                                lowPriceWarningEntity.setSku(goodsEntity.getGoodsSn());
-                                lowPriceWarningEntity.setWarningType("00");
-                                lowPriceWarningEntity.setStoreId(storeId+"");
-                                lowPriceWarningEntity.setCreateTime(new Date());
-
-                                lowPriceWarningDao.save(lowPriceWarningEntity);
-                                resultObj.put("errno", 400);
-                                resultObj.put("errmsg", "商品"+goodsEntity.getName()+"的销售价格小于底线价格");
-                                return resultObj;
-                            }
-                        }
+//                        if(productInfo.getBottomLinePrice() != null){
+//                            BigDecimal bottomLinePrice = new BigDecimal(productInfo.getBottomLinePrice());
+//                            if (goodsEntity.getStoreRetailPrice().compareTo(bottomLinePrice) <= -1) {
+//                                LOGGER.error("销售价格小于底线价格");
+//
+//                                // 记录该信息,到价格过低日志表中,这里没有活动id
+//                                Mall2LowPriceWarningEntity lowPriceWarningEntity = new Mall2LowPriceWarningEntity();
+//                                lowPriceWarningEntity.setSalePrice(goodsEntity.getStoreRetailPrice());
+//                                lowPriceWarningEntity.setWarningPrice(bottomLinePrice);
+//                                lowPriceWarningEntity.setSku(goodsEntity.getGoodsSn());
+//                                lowPriceWarningEntity.setWarningType("00");
+//                                lowPriceWarningEntity.setStoreId(storeId+"");
+//                                lowPriceWarningEntity.setCreateTime(new Date());
+//
+//                                lowPriceWarningDao.save(lowPriceWarningEntity);
+//                                resultObj.put("errno", 400);
+//                                resultObj.put("errmsg", "商品"+goodsEntity.getName()+"的销售价格小于底线价格");
+//                                return resultObj;
+//                            }
+//                        }
 
 
                         productInfo.setStockNum(productInfo.getStockNum() - sellVolume);
@@ -1812,6 +1815,16 @@ public class OrderServiceImpl implements OrderService {
                     }
 
 
+                    if(goodsDto.get("goodstaxes") instanceof Double){
+                       totalTax =  totalTax.add(new BigDecimal((Double)goodsDto.get("goodstaxes"))); // 实际支付价格
+                    }else if(goodsDto.get("goodstaxes") instanceof Integer){
+                       totalTax = totalTax.add(new BigDecimal((Integer)goodsDto.get("goodstaxes")));
+                    }else if(goodsDto.get("goodstaxes") instanceof Float){
+                        totalTax = totalTax.add(new BigDecimal((Float)goodsDto.get("goodstaxes")));
+                    }else if(goodsDto.get("goodstaxes") instanceof String){
+                        totalTax = totalTax.add(new BigDecimal((String) goodsDto.get("goodstaxes")));
+                    }
+
 
 
 //                    goodsEntity.setStoreRetailPrice(productInfo.getRetailPrice());
@@ -1879,7 +1892,7 @@ public class OrderServiceImpl implements OrderService {
 
             // 生成订单
             String merchOrderSn = "EMATO" + CommonUtil.generateOrderNumber();
-            OrderVo order = setOrderVo(goodsEntities, userEntity,storeId.longValue(), user.getMerchSn(),disCountAmount);
+            OrderVo order = setOrderVo(goodsEntities, userEntity,storeId.longValue(), user.getMerchSn(),disCountAmount,totalTax);
             order.setStore_id(storeId.longValue());
 //            if(storeTopic != null){
 //                order.setActivity_id(storeTopic.getId().longValue());
@@ -1932,10 +1945,10 @@ public class OrderServiceImpl implements OrderService {
             // 支付宝支付
 //            AliPay(user, parCode , order, processRecordEntity, orderWXPayRecordCurrent, store);
             OrderEntity orderEntity = queryObject(order.getId());
-            orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
-            orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
+//            orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
+//            orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
 //            orderEntity.setPayFlag(payFlag);
-            orderEntity.setPayTime(new Date());
+//            orderEntity.setPayTime(new Date());
             orderDao.update(orderEntity);
             resultObj.put("shopName",store.getStoreName()); // 根据门店编号查询
             resultObj.put("userName",user.getUsername());
@@ -2379,7 +2392,7 @@ public class OrderServiceImpl implements OrderService {
      * 设置订单数据
      * @return
      */
-    public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser,Long storeId, String merchSn, BigDecimal disCountAmount){
+    public OrderVo setOrderVo(List<GoodsEntity> goodsList, UserEntity loginUser, Long storeId, String merchSn, BigDecimal disCountAmount, BigDecimal totalTax){
         OrderVo orderInfo = new OrderVo();
 
         BigDecimal goodsTotalPrice = new BigDecimal(0.00);
@@ -2397,10 +2410,18 @@ public class OrderServiceImpl implements OrderService {
                     .add(goodsEntity.getActualPaymentAmount().multiply(new BigDecimal(goodsEntity.getGoodsNumber()))).setScale(2,RoundingMode.HALF_UP);
 
         }
+
+
         BigDecimal orderTotalPrice = goodsTotalPrice.add(new BigDecimal(0));
         fullCutCouponDec = fullCutCouponDec.add(couponPrice).setScale(2,RoundingMode.HALF_UP);
 
-        String orderSn = "CW" +  CommonUtil.generateOrderNumber();
+        // 加上税额
+        goodsTotalPrice = goodsTotalPrice.add(totalTax).setScale(2,RoundingMode.HALF_UP);
+        orderTotalPrice = orderTotalPrice.add(totalTax).setScale(2,RoundingMode.HALF_UP);
+
+
+
+        String orderSn = "ZWCW" +  CommonUtil.generateOrderNumber();
         orderInfo.setOrder_sn(orderSn);
         orderInfo.setMerchSn(merchSn);
         orderInfo.setUser_id(loginUser.getId().longValue());

+ 5 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/UserServiceImpl.java

@@ -100,4 +100,9 @@ public class UserServiceImpl implements UserService {
         }
         return null;
     }
+
+    @Override
+    public UserEntity queryByMobile(String mobile) {
+        return userDao.queryByMobile(mobile);
+    }
 }

+ 1 - 1
kmall-admin/src/main/java/com/kmall/admin/task/TestTask.java

@@ -41,7 +41,7 @@ public class TestTask {
 
 
 
-//    @Scheduled(cron = "0/5 * * * * ?")
+    @Scheduled(cron = "0/5 * * * * ?")
     public void flushPickUpCode() {
         logger.info("flushPickUpCode-----------------" );
 

+ 4 - 3
kmall-admin/src/main/webapp/WEB-INF/page/sale/sale.html

@@ -63,7 +63,7 @@
                             <img style="height: 400px;width: 400px;" :src="goods.primaryPicUrl" class="img-rounded"/>
                             <h1 style="margin: 8px;"><strong>{{goods.name}}</strong></h1>
                             <p style="margin: 8px;">单价: <strong>{{goods.retailPrice}}</strong> /元</p>
-                            <p style="margin: 8px;">税费: <strong>{{goods.tax}}</strong> /元</p>
+                            <p style="margin: 8px;">税费: <strong>{{goods.goodstaxes}}</strong> /元</p>
                             <p style="margin: 8px;">规格: {{goods.specification}}</p>
                             <p style="margin: 8px;">条形码: {{goods.prodBarcode}}</p>
                             <!--<span style="margin: 8px;">商品描述: {{goods.goodsDesc}}</span>-->
@@ -83,8 +83,8 @@
                                 <th style="width: 350px;padding: 7px">跨境商品名称</th>
                                 <th style="padding: 7px">单价</th>
                                 <th style="padding: 7px">优惠金额</th>
-                                <th style="padding: 7px">实际支付价</th>
                                 <th style="padding: 7px">税费</th>
+                                <th style="padding: 7px">实际支付价</th>
 <!--                                <th>税费</th>-->
                                 <th style="padding: 7px">数量</th>
 <!--                                <th>操作</th>-->
@@ -94,8 +94,8 @@
                                 <td><h3>{{item.name}}</h3></td>
                                 <td> {{item.retailPrice}}</td>
                                 <td> {{item.discountedPrice}}</td>
+                                <td> {{item.goodstaxes}}</td>
                                 <td> {{item.actualPaymentAmount}}</td>
-                                <td> {{item.specification}}</td>
                                 <td>
 <!--                                    <i class="glyphicon glyphicon-minus" aria-hidden="true" @click="minus(item.id)"></i>-->
                                     {{item.sellVolume}}
@@ -172,6 +172,7 @@
                                     </div>
                                     <div class="modal-footer">
                                         <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
+                                        <button type="button" class="btn btn-primary" @click="queryIDCardInfo">查询身份信息</button>
                                         <button type="button" class="btn btn-primary" @click="getIDCardInfo" id="IDCard">读取身份证信息</button>
                                         <button type="button" class="btn btn-primary" @click="submitCustomInfo" id="Send">去付款</button>
                                     </div>

+ 18 - 27
kmall-admin/src/main/webapp/js/sale/sale.js

@@ -559,30 +559,21 @@ let vm = new Vue({
             // 优惠券
             vm.coupons = new Map();
         },
-        // getIDCardInfo: function(){
-        //     $.get("../order/getIdCardInfo", function (r){
-        //         if(r.code === 0){
-        //             if(!r.info){
-        //                 alert("请连接设备或设备有问题,请联系管理员!");
-        //                 return ;
-        //             }
-        //             var data = JSON.parse(r.info);
-        //             if(data.code=="0"){
-        //                 vm.$refs.customName.value = data.rows[0].data.name;
-        //                 vm.$refs.customIDCard.value = data.rows[0].data.id_no;
-        //             }else{
-        //                 alert(data.msg);
-        //                 return ;
-        //             }
-        //
-        //         }else{
-        //             alter("请连接设备或设备有问题,请联系管理员!");
-        //         }
-        //     });
-        //
-        // },
+        queryIDCardInfo: function(){
+            $.get("../order/queryIDCardInfo/"+vm.$refs.customPhone.value, function (r){
+                if(r.code === 0){
+                    var data = r.userEntity;
+                    vm.$refs.customName.value = data.username;
+                    vm.$refs.customIDCard.value = data.idNo;
+
+                }else{
+                    alert(r.msg);
+                }
+            });
+
+        },
         getIDCardInfo: function(){
-            $.post("http://127.0.0.1:8000/idcard/read", function (r){
+            $.post("http://127.0.0.1:21600/idcard/read", function (r){
                 // var dataR = JSON.parse(r);
                 // console.log(dataR)
                 console.log(r)
@@ -863,10 +854,10 @@ function printArea2(content) {
         + '</div>');
     doc.close();
     var frameWindow = iframe.contentWindow;
-    frameWindow.close();
     frameWindow.focus();
     frameWindow.print();
     frameWindow.print();
+    frameWindow.close();
 }
 var removePrintArea = function (id) {
     $("iframe#" + id).remove();
@@ -886,8 +877,8 @@ function openWebSocket() {
         //无法使用wss,浏览器打开WebSocket时报错
         //ws对应http、wss对应https。
         // webSocket = new WebSocket("ws://183.62.225.124:8080/ws/server/"+storeId);
-        // webSocket = new WebSocket("ws://127.0.0.1:8080//ws/server/"+storeId);
-        webSocket = new WebSocket("wss://cb.k1net.cn/ws/server/"+storeId);
+        webSocket = new WebSocket("ws://127.0.0.1:8080//ws/server/"+storeId);
+        // webSocket = new WebSocket("wss://cb.k1net.cn/ws/server/"+storeId);
         if (webSocket.readyState === webSocket.CONNECTING) {
             console.log('1.连接正在打开......');
         }
@@ -904,8 +895,8 @@ function openWebSocket() {
         };
         //收到消息事件
         webSocket.onmessage = function (msg) {
-
             var data = Object.assign({}, JSON.parse(msg.data));
+            console.log('3.接收到服务端信息......data:'+data);
             vm.sessionId = data.sessionId;
             vm.pickUpCodeList = [];
             if(data.pickUpCodeList.length > 0){

+ 1 - 1
kmall-admin/src/main/webapp/userLogin.html

@@ -93,7 +93,7 @@
             // TODO 调用接口获取机器码
 
                 $.ajax({
-                    url:"http://127.0.0.1:8000/api/reg/gen",
+                    url:"http://127.0.0.1:21600/api/reg/gen",
                     success:function(r){
                         if(r.code == "0"){
                             vm.machineCode = r.rows[0].data.code;