ソースを参照

添加重发单证的功能

zcb 4 年 前
コミット
a7ff4fe69f

+ 30 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java

@@ -1029,6 +1029,36 @@ public class OrderController {
 
     }
 
+    @RequestMapping("/resendOrderToCCNET/{orderSn}/{resendType}")
+    public String resendWayBill(@PathVariable("orderSn") String orderSn, @PathVariable("resendType") String resendType){
+
+        String response = null;
+        Map map = new HashMap();
+        map.put("orderSn",orderSn);
+        try {
+            String url = "";
+            if("waybill".equals(resendType)){
+                url = OmsMerchPropertiesBuilder.instance().getWxOrderResendUrl() + "/resendWaybill/"+orderSn;
+
+            }else if("payment".equals(resendType)){
+                url = OmsMerchPropertiesBuilder.instance().getWxOrderResendUrl() + "/resendPayment/"+orderSn;
+            }else if("notice".equals(resendType)){
+                url = OmsMerchPropertiesBuilder.instance().getWxOrderResendUrl() + "/notice/"+orderSn;
+            }
+            // 同步访问,返回结果字符串
+            response = OkHttpUtils.post(map, url, "SSL");
+            ResponseData responseData = JacksonUtils.fromStringJson(response, ResponseData.class);
+            if(responseData.getCode().equalsIgnoreCase("0")){
+                List<WxOrderEntity> list = responseData.getData().getRows();
+            }
+        } catch (Exception e) {
+            logger.error("查询失败。"+e.getMessage());
+        }
+
+
+        return response;
+    }
+
 
     @RequestMapping("/orderDetail/{orderSn}")
     public R orderDetail(@PathVariable("orderSn") String orderSn) throws IOException {

+ 8 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/GoodsDao.java

@@ -52,4 +52,12 @@ public interface GoodsDao extends BaseDao<GoodsEntity> {
     GoodsEntity queryByBarcode(@Param("barCode") String barCode);
 
     GoodsEntity queryBySku(@Param("sku") String sku);
+
+    /**
+     * 查询所有的sku
+     * @param prodBarcode
+     * @param storeId
+     * @return
+     */
+    List<GoodsEntity> queryListByBarcode(@Param("prodBarcode")String prodBarcode, @Param("storeId")Integer storeId);
 }

+ 121 - 88
kmall-admin/src/main/java/com/kmall/admin/service/impl/OrderServiceImpl.java

@@ -1746,43 +1746,59 @@ public class OrderServiceImpl implements OrderService {
 
             // 检查库存和更新库存
             for (LinkedHashMap goodsDto : goodsList) {
-                //
-                GoodsEntity goodsEntity = goodsDao.queryObjectByProdBarcodeAndStore((String) goodsDto.get("prodBarcode"),storeId);
-                if (goodsEntity == null) {
-                    resultObj.put("errno", 400);
-                    resultObj.put("errmsg", "订单提交失败:商品不存在");
-                    return resultObj;
-                }
-
-
-
+                // 要购买的数量
                 Integer sellVolume = (Integer)goodsDto.get("sellVolume");
 
-                goodsDto.put("goodsId",goodsEntity.getId());
-                goodsDto.put("goodsSn",goodsEntity.getGoodsSn());
-                goodsDto.put("productId",goodsEntity.getProductId());
-                goodsDto.put("storeMarketPrice",goodsEntity.getStoreMarketPrice());
-
-                if(goodsDto.get("actualPaymentAmount") instanceof Double){
-                    goodsDto.put("storeRetailPrice",new BigDecimal((Double)goodsDto.get("actualPaymentAmount")));
-                }else if(goodsDto.get("actualPaymentAmount") instanceof Integer){
-                    goodsDto.put("storeRetailPrice",new BigDecimal((Integer)goodsDto.get("actualPaymentAmount")));
-                }else if(goodsDto.get("actualPaymentAmount") instanceof Float){
-                    goodsDto.put("storeRetailPrice",new BigDecimal((Float)goodsDto.get("actualPaymentAmount")));
+                Integer goodsSellNumber = (Integer)goodsDto.get("sellVolume");
+
+                String prodBarcode = (String) goodsDto.get("prodBarcode");
+
+                Map<GoodsEntity,Integer> numberMap = new HashMap<>();
+                List<GoodsEntity> queryGoodsList = goodsDao.queryListByBarcode(prodBarcode,storeId);
+                if(queryGoodsList != null && queryGoodsList.size() != 0) {
+                    for (GoodsEntity goodsEntity : queryGoodsList) {
+                        // 如果当前还有需要购买的
+                        if (sellVolume > 0) {
+                            // 当前商品剩余的数量
+                            Integer remainAmount = goodsEntity.getGoodsNumber();
+                            if (sellVolume >= remainAmount) {
+                                // 证明该sku库存不足,需要继续向下个sku消费
+                                sellVolume -= remainAmount;
+                                // 记录该商品用了多少个数量
+                                numberMap.put(goodsEntity, remainAmount);
+                            } else {
+                                // 记录该商品用了多少个数量
+                                numberMap.put(goodsEntity, sellVolume);
+                                sellVolume = 0;
+                            }
+                        }
+                    }
                 }
 
+                if(sellVolume > 0){
+                    resultObj.put("errno", 400);
+                    resultObj.put("errmsg", "订单提交失败:条形码:"+prodBarcode+",电商门店库存不足");
+                    return resultObj;
+                }
 
-                //取得规格的信息,判断规格库存
-                ProductStoreRelaEntity productInfo = productStoreRelaDao
-                        .queryByGoodsIdAndStoreId(Long.valueOf(storeId), Long.valueOf(goodsEntity.getId()));
-                synchronized (productInfo) {
-                    if (null == productInfo || null == productInfo.getStockNum() ||
-                            productInfo.getStockNum() < (sellVolume)) {
-                        resultObj.put("errno", 400);
-                        resultObj.put("errmsg", "库存不足,仅剩余" + productInfo.getStockNum());
-                        return resultObj;
-                    } else {
-                        // 判断销售价是否低于底线价
+                Iterator<GoodsEntity> goodsIterator = numberMap.keySet().iterator();
+                // 循环购买的商品map,重新计算数量跟价格
+                while(goodsIterator.hasNext()){
+                    GoodsEntity goodsEntity = goodsIterator.next();
+                    // 该商品购买数量
+                    Integer num = numberMap.get(goodsEntity);
+                    //取得规格的信息,判断规格库存
+                    ProductStoreRelaEntity productInfo = productStoreRelaDao
+                            .queryByGoodsIdAndStoreId(Long.valueOf(storeId), Long.valueOf(goodsEntity.getId()));
+                    synchronized (productInfo) {
+                        if (null == productInfo || null == productInfo.getStockNum() ||
+                                productInfo.getStockNum() < (num)) {
+                            resultObj.put("errno", 400);
+                            resultObj.put("errmsg", "条形码:"+prodBarcode+",电商门店库存不足,仅剩余" + productInfo.getStockNum());
+                            return resultObj;
+                        }
+                        else {
+                            // 判断销售价是否低于底线价
 //                        if(productInfo.getBottomLinePrice() != null){
 //                            BigDecimal bottomLinePrice = new BigDecimal(productInfo.getBottomLinePrice());
 //                            if (goodsEntity.getStoreRetailPrice().compareTo(bottomLinePrice) <= -1) {
@@ -1803,77 +1819,94 @@ public class OrderServiceImpl implements OrderService {
 //                                return resultObj;
 //                            }
 //                        }
+                            productInfo.setStockNum(productInfo.getStockNum() - num);
+                            productInfo.setStoreId(Long.valueOf(storeId));
+                            productInfo.setSellVolume(productInfo.getSellVolume() + num);
+//                            productInfo.addSellVolume();
+                            productInfo.setLastSaleTime(new Date());
+                            productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
+
+                            if(goodsEntity != null) {
+                                goodsEntity.setGoodsNumber(goodsEntity.getGoodsNumber() - num);
+                                goodsEntity.setLastSaleTime(new Date());
+                                goodsDao.update(goodsEntity);
+                            }
+                        }
 
 
-                        productInfo.setStockNum(productInfo.getStockNum() - sellVolume);
-                        productInfo.setStoreId(Long.valueOf(storeId));
-                        productInfo.addSellVolume();
-                        productInfo.setLastSaleTime(new Date());
-                        productStoreRelaDao.updateStockNum(productInfo);//修改普通商品库存
+                        BigDecimal retailPrice = new BigDecimal(0);
+                        BigDecimal storeRetailPrice = new BigDecimal(0);
+                        if(goodsDto.get("retailPrice") instanceof Double){
 
-                        if(goodsEntity != null) {
-                            goodsEntity.setGoodsNumber(goodsEntity.getGoodsNumber() - sellVolume);
-                            goodsEntity.setLastSaleTime(new Date());
-                            goodsDao.update(goodsEntity);
+                            retailPrice = new BigDecimal((Double)goodsDto.get("retailPrice")); // 单价
+                            storeRetailPrice = new BigDecimal((Double)goodsDto.get("retailPrice")); // 单价
+                        }else if(goodsDto.get("retailPrice") instanceof Integer){
+                            retailPrice = new BigDecimal((Integer)goodsDto.get("retailPrice"));
+                            storeRetailPrice = new BigDecimal((Integer)goodsDto.get("retailPrice"));
+                        }else if(goodsDto.get("retailPrice") instanceof Float){
+                            retailPrice = new BigDecimal((Float)goodsDto.get("retailPrice"));
+                            storeRetailPrice = new BigDecimal((Float)goodsDto.get("retailPrice"));
                         }
-                    }
 
+                        BigDecimal disCountedPrice = new BigDecimal(0);
+                        BigDecimal actualPaymentAmount = new BigDecimal(0);
 
+                        if(goodsDto.get("discountedPrice") instanceof Double){
+                            disCountedPrice = new BigDecimal((Double)goodsDto.get("discountedPrice")); // 优惠金额
+                        }else if(goodsDto.get("discountedPrice") instanceof Integer){
+                            disCountedPrice = new BigDecimal((Integer)goodsDto.get("discountedPrice"));
+                        }else if(goodsDto.get("discountedPrice") instanceof Float){
+                            disCountedPrice = new BigDecimal((Float)goodsDto.get("discountedPrice"));
+                        }
+                        if(goodsDto.get("actualPaymentAmount") instanceof Double){
+                            actualPaymentAmount = new BigDecimal((Double)goodsDto.get("actualPaymentAmount")); // 实际支付价格
+                        }else if(goodsDto.get("actualPaymentAmount") instanceof Integer){
+                            actualPaymentAmount = new BigDecimal((Integer)goodsDto.get("actualPaymentAmount"));
+                        }else if(goodsDto.get("actualPaymentAmount") instanceof Float){
+                            actualPaymentAmount = new BigDecimal((Float)goodsDto.get("actualPaymentAmount"));
+                        }
+                        disCountedPrice = disCountedPrice
+                                .divide(new BigDecimal(goodsSellNumber),3,RoundingMode.HALF_UP)
+                                .multiply(new BigDecimal(num))
+                                .setScale(2,RoundingMode.HALF_UP);
+                        actualPaymentAmount = actualPaymentAmount
+                                .divide(new BigDecimal(goodsSellNumber),3,RoundingMode.HALF_UP)
+                                .multiply(new BigDecimal(num))
+                                .setScale(2,RoundingMode.HALF_UP);
 
 
-                    if(goodsDto.get("retailPrice") instanceof Double){
-                        goodsEntity.setRetailPrice(new BigDecimal((Double)goodsDto.get("retailPrice"))); // 单价
-                    }else if(goodsDto.get("retailPrice") instanceof Integer){
-                        goodsEntity.setRetailPrice(new BigDecimal((Integer)goodsDto.get("retailPrice")));
-                    }else if(goodsDto.get("retailPrice") instanceof Float){
-                        goodsEntity.setRetailPrice(new BigDecimal((Float)goodsDto.get("retailPrice")));
-                    }
-                    if(goodsDto.get("discountedPrice") instanceof Double){
-                        goodsEntity.setDiscountedPrice(new BigDecimal((Double)goodsDto.get("discountedPrice"))); // 优惠金额
-                    }else if(goodsDto.get("discountedPrice") instanceof Integer){
-                        goodsEntity.setDiscountedPrice(new BigDecimal((Integer)goodsDto.get("discountedPrice")));
-                    }else if(goodsDto.get("discountedPrice") instanceof Float){
-                        goodsEntity.setDiscountedPrice(new BigDecimal((Float)goodsDto.get("discountedPrice")));
-                    }
-                    if(goodsDto.get("actualPaymentAmount") instanceof Double){
-                        goodsEntity.setActualPaymentAmount(new BigDecimal((Double)goodsDto.get("actualPaymentAmount"))); // 实际支付价格
-                    }else if(goodsDto.get("actualPaymentAmount") instanceof Integer){
-                        goodsEntity.setActualPaymentAmount(new BigDecimal((Integer)goodsDto.get("actualPaymentAmount")));
-                    }else if(goodsDto.get("actualPaymentAmount") instanceof Float){
-                        goodsEntity.setActualPaymentAmount(new BigDecimal((Float)goodsDto.get("actualPaymentAmount")));
-                    }
+                        goodsEntity.setRetailPrice(retailPrice);
+                        goodsEntity.setStoreRetailPrice(storeRetailPrice);
+                        goodsEntity.setDiscountedPrice(disCountedPrice);
+                        goodsEntity.setActualPaymentAmount(actualPaymentAmount);
 
 
-                    Object taxObject = goodsDto.get("goodstaxes");
-                    BigDecimal tax = new BigDecimal(0);
-                    if(taxObject instanceof Double){
-                       tax = new BigDecimal((Double) taxObject);
-                    }else if(taxObject instanceof Integer){
-                        tax = new BigDecimal((Integer) taxObject);
-                    }else if(taxObject instanceof Float){
-                        tax = new BigDecimal((Float) taxObject);
-                    }else if(taxObject instanceof String){
-                        tax = new BigDecimal((String) taxObject) ;
-                    }
-                    totalTax = totalTax.add(tax).setScale(2,BigDecimal.ROUND_HALF_DOWN); // 计算总的税额
-
-                    if(goodsDto.get("retailPrice") instanceof Double){
-                        goodsEntity.setStoreRetailPrice(new BigDecimal((Double)goodsDto.get("retailPrice"))); // 单价
-                    }else if(goodsDto.get("retailPrice") instanceof Integer){
-                        goodsEntity.setStoreRetailPrice(new BigDecimal((Integer)goodsDto.get("retailPrice")));
-                    }else if(goodsDto.get("retailPrice") instanceof Float){
-                        goodsEntity.setStoreRetailPrice(new BigDecimal((Float)goodsDto.get("retailPrice")));
-                    }
 
+                        // 借用这个字段来存储购买数
+                        goodsEntity.setGoodsNumber(num);
+                        goodsEntity.setActivity((String) goodsDto.get("activity"));
+                        goodsEntities.add(goodsEntity);
+                    }
 
-//                    goodsEntity.setStoreRetailPrice(productInfo.getRetailPrice());
-                    // 借用这个字段来存储购买数
-                    goodsEntity.setGoodsNumber(sellVolume);
 
-                    goodsEntity.setActivity((String) goodsDto.get("activity"));
+                }
 
-                    goodsEntities.add(goodsEntity);
+                // 计算该购物车所需要的所有税费
+                Object taxObject = goodsDto.get("goodstaxes");
+                BigDecimal tax = new BigDecimal(0);
+                if(taxObject instanceof Double){
+                    tax = new BigDecimal((Double) taxObject);
+                }else if(taxObject instanceof Integer){
+                    tax = new BigDecimal((Integer) taxObject);
+                }else if(taxObject instanceof Float){
+                    tax = new BigDecimal((Float) taxObject);
+                }else if(taxObject instanceof String){
+                    tax = new BigDecimal((String) taxObject) ;
                 }
+                totalTax = totalTax.add(tax).setScale(2,BigDecimal.ROUND_HALF_DOWN); // 计算总的税额
+
+
+
             }
 
 

+ 11 - 0
kmall-admin/src/main/resources/mybatis/mapper/GoodsDao.xml

@@ -731,5 +731,16 @@
         where sku = #{sku}
     </select>
 
+    <select id="queryListByBarcode" resultType="com.kmall.admin.entity.GoodsEntity">
+         SELECT
+            a.id,a.sku,a.goods_number,a.goods_sn,a.name,a.list_pic_url,a.prod_barcode,r.market_price storeMarketPrice,r.retail_price storeRetailPrice ,r.stock_num,s.store_name,r.product_id,s.id 'storeId',a.goods_rate as goodsRate
+        FROM
+            mall_goods a
+        LEFT JOIN mall_product_store_rela r ON r.goods_id = a.id
+        inner join mall_store s on r.store_id=s.id
+        where a.prod_barcode = #{prodBarcode}  and r.store_id = #{storeId}
+        and r.stock_num > 0
+    </select>
+
 
 </mapper>

+ 1 - 0
kmall-admin/src/main/resources/mybatis/mapper/UserDao.xml

@@ -131,6 +131,7 @@
         <set>
             <if test="username != null">`username` = #{username},</if>
             <if test="password != null">`password` = #{password},</if>
+            <if test="idNo != null">`id_no` =  #{idNo},</if>
             <if test="gender != null">`gender` = #{gender},</if>
             <if test="birthday != null">`birthday` = #{birthday},</if>
             <if test="registerTime != null">`register_time` = #{registerTime},</if>

+ 5 - 1
kmall-admin/src/main/webapp/WEB-INF/page/sale/sale.html

@@ -111,7 +111,8 @@
                     </li>
                     <li>
                         <ul>
-                            <li><h3 style="border: white;padding: 8px">总价:{{totalPrice}}</h3></li>
+                            <li><h3 style="border: white;padding: 8px;">总件数:{{totalCount}}</h3></li>
+                            <li><h3 style="border: white;padding: 8px;">总价:{{totalPrice}}</h3></li>
                             <li><h3 style="border: white;padding: 8px">优惠价:{{discountedPrice}}</h3></li>
                             <li><h3 style="border: white;padding: 8px">实际支付价:{{actualPrice}}</h3></li>
                             <li v-if="showReduceMoney != 0"><h3 style="border: white;padding: 8px">满减:{{showReduceMoney}}</h3></li>
@@ -299,6 +300,9 @@
                         </div>
                         <div class="modal-footer">
                             <button type="button" style="margin:0 30px 0 20px;font-size: 20px;float: left" class="btn ivu-btn-error" @click="refundOrder()" id="refundOrder" data-dismiss="modal">退款</button>
+                            <button type="button" style="margin:0 30px 0 20px;font-size: 30px;" class="btn btn-primary" @click="resendNotice" id="resendNotice" data-dismiss="modal">重发通知</button>
+                            <button type="button" style="margin:0 30px 0 20px;font-size: 30px;" class="btn btn-primary" @click="resendWaybill" id="resendWaybill" data-dismiss="modal">重发运单</button>
+                            <button type="button" style="margin:0 30px 0 20px;font-size: 30px;" class="btn btn-primary" @click="resendPayment" id="resendPayment" data-dismiss="modal">重发支付单</button>
                             <button type="button" style="margin:0 30px 0 20px;font-size: 30px;" class="btn btn-primary" @click="verification" id="verification" data-dismiss="modal">核销</button>
                             <!--<button type="button" class="btn btn-primary" @click="retrySendOrder" id="retrySendOrder" data-dismiss="modal">订单重推</button>-->
                         </div>

+ 38 - 3
kmall-admin/src/main/webapp/js/sale/sale.js

@@ -564,7 +564,12 @@ let vm = new Vue({
         goodsMap:new Map(),
         response: "",
 
+        // 支付码
         parCode : "",
+
+        // 总件数
+        totalCount:0,
+
     },
     methods: {
 
@@ -701,6 +706,7 @@ let vm = new Vue({
 
 
                     vm.totalPrice = vm.totalPrice - (goods.retailPrice * goods.sellVolume);
+                    vm.totalCount = vm.totalCount - (goods.sellVolume);
                     vm.discountedPrice = vm.discountedPrice - goods.discountedPrice;
                     vm.actualPrice = vm.actualPrice - goods.actualPaymentAmount;
                     vm.boughtNum.delete(goods.prodBarcode);
@@ -783,6 +789,7 @@ let vm = new Vue({
 
         },customClearData: function(){
             vm.totalPrice = 0;
+            vm.totalCount = 0;
             vm.discountedPrice = 0;
             vm.actualPrice = 0;
             vm.goods={};
@@ -951,6 +958,27 @@ let vm = new Vue({
                 }
             });
         },
+        resendNotice:function(){
+            confirm('确认重发重置吗?', function () {
+                $.get("../order/resendOrderToCCNET/"+vm.currentOrderNo+"/notice", function (r) {
+                    alert(r);
+                });
+            })
+        },
+        resendWaybill:function(){
+            confirm('确认重发运单吗?', function () {
+                $.get("../order/resendOrderToCCNET/"+vm.currentOrderNo+"/waybill", function (r) {
+                    alert(r);
+                });
+            })
+        },
+        resendPayment:function(){
+            confirm('确认重发支付单吗?', function () {
+                $.get("../order/resendOrderToCCNET/"+vm.currentOrderNo+"/payment", function (r) {
+                    alert(r);
+                });
+            })
+        },
         verification:function(){
 
             if(vm.orderProcessRecord.isCustomsSend != 1){
@@ -961,7 +989,7 @@ let vm = new Vue({
             confirm('确认核销吗?', function () {
                 $.ajax({
                     type: "POST",
-                    url: "../order/printMsgAndChangeCode",
+                    url: "../order/resendOrderToCCNET",
                     contentType: "application/json",
                     data: JSON.stringify({'id':vm.currentOrderNo,'sessionId':vm.sessionId}),
                     success: function (r) {
@@ -1154,8 +1182,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.连接正在打开......');
         }
@@ -1523,6 +1551,13 @@ function handle(goodsDetails,operatorType){
         vm.index = vm.index + 1;
     }
     vm.totalPrice = (vm.totalPrice + data.retailPrice);
+
+    if("minus" == operatorType){
+        vm.totalCount = vm.totalCount - 1;
+    }else{
+        vm.totalCount = vm.totalCount + 1;
+    }
+
     if(vm.reduceMoney > 0){
         vm.discountedPrice = vm.discountedPrice + data.discountedPrice + vm.reduceMoney;
         vm.actualPrice = vm.actualPrice + data.actualPaymentAmount - vm.reduceMoney;