Browse Source

1.税费计算修改
2.异常税费记录添加

zcb 4 years ago
parent
commit
6f136e18fb

+ 37 - 15
kmall-admin/src/main/java/com/kmall/admin/controller/OrderController.java

@@ -5,6 +5,7 @@ import com.kmall.admin.dto.SystemFormatDto;
 import com.kmall.admin.entity.*;
 import com.kmall.admin.fromcomm.entity.SysUserEntity;
 import com.kmall.admin.service.*;
+import com.kmall.admin.utils.CalculateTax;
 import com.kmall.admin.utils.ParamUtils;
 import com.kmall.admin.utils.ShiroUtils;
 import com.kmall.common.constant.Dict;
@@ -76,6 +77,8 @@ public class OrderController {
     private volatile Integer code = 1;
     @Autowired
     private UserService userService;
+    @Autowired
+    private GoodsService goodsService;
 
     /**
      * 列表
@@ -667,9 +670,15 @@ public class OrderController {
             List<OrderGoodsEntity> goodsList = orderGoodsService.queryList(map);
 
             for (OrderGoodsEntity orderGoodsEntity : goodsList) {
-                BigDecimal goodsTax = orderGoodsEntity.getMarketPrice().divide(new BigDecimal(1).add(orderGoodsEntity.getGoodsRate()),2,RoundingMode.HALF_DOWN).multiply(orderGoodsEntity.getGoodsRate())
-                        .multiply(new BigDecimal(orderGoodsEntity.getNumber())).setScale(2,RoundingMode.HALF_DOWN);
-                tax = tax.add(goodsTax).setScale(2,RoundingMode.HALF_UP);
+                GoodsEntity goodsEntity = goodsService.queryObject(orderGoodsEntity.getGoodsId());
+                BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,orderGoodsEntity.getMarketPrice(),goodsService);
+                goodsTax = goodsTax.multiply(new BigDecimal(orderGoodsEntity.getNumber()));
+                orderGoodsEntity.setTax(goodsTax);
+                tax = tax.add(goodsTax);
+
+//                BigDecimal goodsTax = orderGoodsEntity.getMarketPrice().divide(new BigDecimal(1).add(orderGoodsEntity.getGoodsRate()),2,RoundingMode.HALF_DOWN).multiply(orderGoodsEntity.getGoodsRate())
+//                        .multiply(new BigDecimal(orderGoodsEntity.getNumber())).setScale(2,RoundingMode.HALF_DOWN);
+//                tax = tax.add(goodsTax).setScale(2,RoundingMode.HALF_UP);
             }
             orderEntity.setTax(tax);
         }
@@ -690,11 +699,17 @@ public class OrderController {
         List<OrderGoodsEntity> goodsList = order.getOrderGoodsEntityList();
 
         for (OrderGoodsEntity orderGoodsEntity : goodsList) {
-            BigDecimal goodsTax = orderGoodsEntity.getMarketPrice().divide(new BigDecimal(1).add(orderGoodsEntity.getGoodsRate()),2,RoundingMode.HALF_DOWN).multiply(orderGoodsEntity.getGoodsRate())
-                    .multiply(new BigDecimal(orderGoodsEntity.getNumber())).setScale(2,RoundingMode.HALF_DOWN);
+            GoodsEntity goodsEntity = goodsService.queryObject(orderGoodsEntity.getGoodsId());
+            BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,orderGoodsEntity.getMarketPrice(),goodsService);
+            goodsTax = goodsTax.multiply(new BigDecimal(orderGoodsEntity.getNumber()));
             orderGoodsEntity.setTax(goodsTax);
+            tax = tax.add(goodsTax);
 
-            tax = tax.add(goodsTax).setScale(2,RoundingMode.HALF_UP);
+//            BigDecimal goodsTax = orderGoodsEntity.getMarketPrice().divide(new BigDecimal(1).add(orderGoodsEntity.getGoodsRate()),2,RoundingMode.HALF_DOWN).multiply(orderGoodsEntity.getGoodsRate())
+//                    .multiply(new BigDecimal(orderGoodsEntity.getNumber())).setScale(2,RoundingMode.HALF_DOWN);
+//            orderGoodsEntity.setTax(goodsTax);
+//
+//            tax = tax.add(goodsTax).setScale(2,RoundingMode.HALF_UP);
 
         }
         order.setTax(tax);
@@ -1082,9 +1097,13 @@ public class OrderController {
             BigDecimal retailPrice = orderGoodsEntity.getRetailPrice();
             BigDecimal goodsRate = orderGoodsEntity.getGoodsRate();
             Integer number = orderGoodsEntity.getNumber();
-            BigDecimal goodsTax = retailPrice.divide(new BigDecimal(1).add(goodsRate),2,RoundingMode.HALF_DOWN).multiply(goodsRate).multiply(new BigDecimal(number)).setScale(0,RoundingMode.HALF_DOWN);
+
+            GoodsEntity goodsEntity = goodsService.queryObject(orderEntity.getGoodsId());
+            BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,retailPrice,goodsService);
+            goodsTax = goodsTax.multiply(new BigDecimal(number));
             orderGoodsEntity.setTax(goodsTax);
             tax = tax.add(goodsTax);
+//            BigDecimal goodsTax = retailPrice.divide(new BigDecimal(1).add(goodsRate),2,RoundingMode.HALF_DOWN).multiply(goodsRate).multiply(new BigDecimal(number)).setScale(0,RoundingMode.HALF_DOWN);
         }
         String response = null;
 
@@ -1093,10 +1112,6 @@ public class OrderController {
             String url = OmsMerchPropertiesBuilder.instance().getWxOrderResendUrl() + "/"+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());
         }
@@ -1306,17 +1321,24 @@ public class OrderController {
             for (SystemFormatDto systemFormat : systemFormatList) {
                 LinkedHashMap<String, Object> map = new LinkedHashMap<>(32);
                 if (Objects.nonNull(systemFormat.getTaxRate()) && Objects.nonNull(systemFormat.getTotalSalesInclTax())){
+
+
+                    BigDecimal unitSold = new BigDecimal(systemFormat.getUnitSold());
+
                     // 设置综合税额
                     BigDecimal totalSalesIncTax = new BigDecimal(systemFormat.getTotalSalesInclTax());
-                    BigDecimal taxRate = new BigDecimal(systemFormat.getTaxRate());
-                    systemFormat.setSales(totalSalesIncTax.divide(new BigDecimal(1).add(taxRate),4,RoundingMode.HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
+//                    BigDecimal taxRate = new BigDecimal(systemFormat.getTaxRate());
+                    GoodsEntity goodsEntity = goodsService.queryObject(systemFormat.getGoodsId());
+                    BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity,totalSalesIncTax.divide(unitSold,2,RoundingMode.HALF_UP),goodsService);
+                    goodsTax = goodsTax.multiply(unitSold);
+
+                    systemFormat.setSales(totalSalesIncTax.subtract(goodsTax).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
                     systemFormat.setTaxAmount(totalSalesIncTax.subtract(new BigDecimal(systemFormat.getSales())).setScale(2,BigDecimal.ROUND_HALF_UP).toString());
 
                     // 设置实际销售额
-                    BigDecimal unitSold = new BigDecimal(systemFormat.getUnitSold());
                     systemFormat.setCurrentPrice(totalSalesIncTax.divide(unitSold,2,BigDecimal.ROUND_HALF_UP).setScale(2,BigDecimal.ROUND_HALF_UP).toEngineeringString());
                     if (Dict.orderStatus.item_401.getItem().equals(systemFormat.getOrderStatus())){
-                        systemFormat.setUnitSold("-"+systemFormat.getUnitSold());
+                        systemFormat.setUnitSold("-"+ unitSold);
                         systemFormat.setSales("-"+systemFormat.getSales());
                         systemFormat.setTaxAmount("-"+systemFormat.getTaxAmount());
                         systemFormat.setTotalSalesInclTax("-"+systemFormat.getTotalSalesInclTax());

+ 107 - 0
kmall-admin/src/main/java/com/kmall/admin/controller/TaxErrorRecordController.java

@@ -0,0 +1,107 @@
+package com.kmall.admin.controller;
+
+import java.util.List;
+import java.util.Map;
+
+import com.kmall.admin.entity.TaxErrorRecordEntity;
+import com.kmall.admin.service.TaxErrorRecordService;
+import com.kmall.common.utils.PageUtils;
+import com.kmall.common.utils.Query;
+import com.kmall.common.utils.R;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+
+/**
+ * 税款异常记录表Controller
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2020-12-18 14:37:40
+ */
+@Controller
+@RequestMapping("taxerrorrecord")
+public class TaxErrorRecordController {
+    @Autowired
+    private TaxErrorRecordService taxErrorRecordService;
+
+    /**
+     * 查看列表
+     */
+    @RequestMapping("/list")
+    @RequiresPermissions("taxerrorrecord:list")
+    @ResponseBody
+    public R list(@RequestParam Map<String, Object> params) {
+        //查询列表数据
+        Query query = new Query(params);
+
+        List<TaxErrorRecordEntity> taxErrorRecordList = taxErrorRecordService.queryList(query);
+        int total = taxErrorRecordService.queryTotal(query);
+
+        PageUtils pageUtil = new PageUtils(taxErrorRecordList, total, query.getLimit(), query.getPage());
+
+        return R.ok().put("page", pageUtil);
+    }
+
+    /**
+     * 查看信息
+     */
+    @RequestMapping("/info/{id}")
+    @RequiresPermissions("taxerrorrecord:info")
+    @ResponseBody
+    public R info(@PathVariable("id") Integer id) {
+        TaxErrorRecordEntity taxErrorRecord = taxErrorRecordService.queryObject(id);
+
+        return R.ok().put("taxErrorRecord", taxErrorRecord);
+    }
+
+    /**
+     * 保存
+     */
+    @RequestMapping("/save")
+    @RequiresPermissions("taxerrorrecord:save")
+    @ResponseBody
+    public R save(@RequestBody TaxErrorRecordEntity taxErrorRecord) {
+        taxErrorRecordService.save(taxErrorRecord);
+
+        return R.ok();
+    }
+
+    /**
+     * 修改
+     */
+    @RequestMapping("/update")
+    @RequiresPermissions("taxerrorrecord:update")
+    @ResponseBody
+    public R update(@RequestBody TaxErrorRecordEntity taxErrorRecord) {
+        taxErrorRecordService.update(taxErrorRecord);
+
+        return R.ok();
+    }
+
+    /**
+     * 删除
+     */
+    @RequestMapping("/delete")
+    @RequiresPermissions("taxerrorrecord:delete")
+    @ResponseBody
+    public R delete(@RequestBody Integer[]ids) {
+        taxErrorRecordService.deleteBatch(ids);
+
+        return R.ok();
+    }
+
+    /**
+     * 查看所有列表
+     */
+    @RequestMapping("/queryAll")
+    @ResponseBody
+    public R queryAll(@RequestParam Map<String, Object> params) {
+
+        List<TaxErrorRecordEntity> list = taxErrorRecordService.queryList(params);
+
+        return R.ok().put("list", list);
+    }
+}

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

@@ -3,6 +3,7 @@ package com.kmall.admin.dao;
 import com.kmall.admin.dto.GoodsDetailsDto;
 import com.kmall.admin.dto.GoodsPanoramaDto;
 import com.kmall.admin.entity.GoodsEntity;
+import com.kmall.admin.entity.TaxErrorRecordEntity;
 import com.kmall.api.entity.exportpdf.PDFGoodsDto;
 import com.kmall.manager.dao.BaseDao;
 import org.apache.ibatis.annotations.Param;
@@ -73,4 +74,5 @@ public interface GoodsDao extends BaseDao<GoodsEntity> {
     List<GoodsEntity> queryAllList();
 
     GoodsEntity queryByBarcodeAndSku(@Param("prodBarcode") String prodBarcode, @Param("goodsSn") String goodsSn);
+
 }

+ 16 - 0
kmall-admin/src/main/java/com/kmall/admin/dao/TaxErrorRecordDao.java

@@ -0,0 +1,16 @@
+package com.kmall.admin.dao;
+
+
+import com.kmall.admin.entity.TaxErrorRecordEntity;
+import com.kmall.manager.dao.BaseDao;
+
+/**
+ * 税款异常记录表Dao
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2020-12-18 14:37:40
+ */
+public interface TaxErrorRecordDao extends BaseDao<TaxErrorRecordEntity> {
+
+}

+ 9 - 0
kmall-admin/src/main/java/com/kmall/admin/dto/SystemFormatDto.java

@@ -42,6 +42,7 @@ public class SystemFormatDto implements Serializable {
     private String transactionType;// 销售类型
     private String saleReturnType;// 退货类型
     private String remark;// 备注
+    private Integer goodsId; // 商品id
 
     private String orderStatus;//订单状态
 
@@ -309,4 +310,12 @@ public class SystemFormatDto implements Serializable {
     public void setRemark(String remark) {
         this.remark = remark;
     }
+
+    public Integer getGoodsId() {
+        return goodsId;
+    }
+
+    public void setGoodsId(Integer goodsId) {
+        this.goodsId = goodsId;
+    }
 }

+ 171 - 0
kmall-admin/src/main/java/com/kmall/admin/entity/TaxErrorRecordEntity.java

@@ -0,0 +1,171 @@
+package com.kmall.admin.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 税款异常记录表实体
+ * 表名 mall_tax_error_record
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2020-12-18 14:37:40
+ */
+public class TaxErrorRecordEntity implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private Integer id;
+    /**
+     * 料件号
+     */
+    private String sku;
+    /**
+     * 税率
+     */
+    private String goodsRate;
+    /**
+     * 金额
+     */
+    private String money;
+    /**
+     * 异常发生时间
+     */
+    private Date errorTime;
+    /**
+     * 是否修改过
+     */
+    private String handle;
+    /**
+     * 修改人编号
+     */
+    private String moderSn;
+    /**
+     * 修改时间
+     */
+    private Date modTime;
+    /**
+     * 时间戳
+     */
+    private Date tstm;
+
+    /**
+     * 设置:编号
+     */
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    /**
+     * 获取:编号
+     */
+    public Integer getId() {
+        return id;
+    }
+    /**
+     * 设置:料件号
+     */
+    public void setSku(String sku) {
+        this.sku = sku;
+    }
+
+    /**
+     * 获取:料件号
+     */
+    public String getSku() {
+        return sku;
+    }
+    /**
+     * 设置:税率
+     */
+    public void setGoodsRate(String goodsRate) {
+        this.goodsRate = goodsRate;
+    }
+
+    /**
+     * 获取:税率
+     */
+    public String getGoodsRate() {
+        return goodsRate;
+    }
+    /**
+     * 设置:金额
+     */
+    public void setMoney(String money) {
+        this.money = money;
+    }
+
+    /**
+     * 获取:金额
+     */
+    public String getMoney() {
+        return money;
+    }
+    /**
+     * 设置:异常发生时间
+     */
+    public void setErrorTime(Date errorTime) {
+        this.errorTime = errorTime;
+    }
+
+    /**
+     * 获取:异常发生时间
+     */
+    public Date getErrorTime() {
+        return errorTime;
+    }
+    /**
+     * 设置:是否修改过
+     */
+    public void setHandle(String handle) {
+        this.handle = handle;
+    }
+
+    /**
+     * 获取:是否修改过
+     */
+    public String getHandle() {
+        return handle;
+    }
+    /**
+     * 设置:修改人编号
+     */
+    public void setModerSn(String moderSn) {
+        this.moderSn = moderSn;
+    }
+
+    /**
+     * 获取:修改人编号
+     */
+    public String getModerSn() {
+        return moderSn;
+    }
+    /**
+     * 设置:修改时间
+     */
+    public void setModTime(Date modTime) {
+        this.modTime = modTime;
+    }
+
+    /**
+     * 获取:修改时间
+     */
+    public Date getModTime() {
+        return modTime;
+    }
+    /**
+     * 设置:时间戳
+     */
+    public void setTstm(Date tstm) {
+        this.tstm = tstm;
+    }
+
+    /**
+     * 获取:时间戳
+     */
+    public Date getTstm() {
+        return tstm;
+    }
+}

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

@@ -4,6 +4,7 @@ import com.kmall.admin.dto.GoodsDetailsDto;
 import com.kmall.admin.dto.GoodsDto;
 import com.kmall.admin.dto.GoodsPanoramaDto;
 import com.kmall.admin.entity.GoodsEntity;
+import com.kmall.admin.entity.TaxErrorRecordEntity;
 import com.kmall.api.entity.exportpdf.PDFGoodsDto;
 
 import java.util.List;
@@ -199,4 +200,8 @@ public interface GoodsService {
 
     void syncGoodsRate();
 
+    void updateTaxErrorRecord(TaxErrorRecordEntity taxErrorRecordEntity);
+    void insertTaxErrorRecord(TaxErrorRecordEntity taxErrorRecordEntity);
+
+    void updateByEntity(GoodsEntity updateGoods);
 }

+ 73 - 0
kmall-admin/src/main/java/com/kmall/admin/service/TaxErrorRecordService.java

@@ -0,0 +1,73 @@
+package com.kmall.admin.service;
+
+
+import com.kmall.admin.entity.TaxErrorRecordEntity;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 税款异常记录表Service接口
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2020-12-18 14:37:40
+ */
+public interface TaxErrorRecordService {
+
+    /**
+     * 根据主键查询实体
+     *
+     * @param id 主键
+     * @return 实体
+     */
+    TaxErrorRecordEntity queryObject(Integer id);
+
+    /**
+     * 分页查询
+     *
+     * @param map 参数
+     * @return list
+     */
+    List<TaxErrorRecordEntity> queryList(Map<String, Object> map);
+
+    /**
+     * 分页统计总数
+     *
+     * @param map 参数
+     * @return 总数
+     */
+    int queryTotal(Map<String, Object> map);
+
+    /**
+     * 保存实体
+     *
+     * @param taxErrorRecord 实体
+     * @return 保存条数
+     */
+    int save(TaxErrorRecordEntity taxErrorRecord);
+
+    /**
+     * 根据主键更新实体
+     *
+     * @param taxErrorRecord 实体
+     * @return 更新条数
+     */
+    int update(TaxErrorRecordEntity taxErrorRecord);
+
+    /**
+     * 根据主键删除
+     *
+     * @param id
+     * @return 删除条数
+     */
+    int delete(Integer id);
+
+    /**
+     * 根据主键批量删除
+     *
+     * @param ids
+     * @return 删除条数
+     */
+    int deleteBatch(Integer[]ids);
+}

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

@@ -81,6 +81,8 @@ public class GoodsServiceImpl implements GoodsService {
     private StoreMngChangeDao storeMngChangeDao;
     @Autowired
     private GoodsUtils goodsUtils;
+    @Autowired
+    private TaxErrorRecordDao taxErrorRecordDao;
 
 
     @Autowired
@@ -1469,20 +1471,9 @@ public class GoodsServiceImpl implements GoodsService {
             return null;
         }
         goods.setDiscountedPrice(new BigDecimal(0));
-        BigDecimal goodsRate = null;
-        try {
-            goodsRate = new BigDecimal(goods.getGoodsRate());
-        } catch (Exception e) {
-            goodsRate = new BigDecimal(0);
-        }
         BigDecimal retailPrice = goods.getRetailPrice();
 
-        GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
 
-        // TODO 算税需要修改
-        CalculateTax.calculateFinalTax(goodsEntity,retailPrice);
-        BigDecimal tax = goodsRate.multiply(retailPrice.divide(new BigDecimal(1).add(goodsRate),2,RoundingMode.HALF_DOWN)).setScale(2,RoundingMode.HALF_DOWN) ;
-        goods.setGoodstaxes(tax.toString());
         goods.setActualPaymentAmount(retailPrice.setScale(2,RoundingMode.HALF_UP));
 
         Map<String,Object> skuActivitiesMap = new HashMap<>();
@@ -1690,10 +1681,6 @@ public class GoodsServiceImpl implements GoodsService {
                 goods.setActualPaymentAmount(discountEntity.getActivityPrice());
                 goods.setRetailPrice(discountEntity.getActivityPrice());
 
-                // TODO 税费需要修改
-                tax = goodsRate.multiply(discountEntity.getActivityPrice().divide(new BigDecimal(1).add(goodsRate),2,RoundingMode.HALF_DOWN)).setScale(2,RoundingMode.HALF_DOWN) ;
-                goods.setGoodstaxes(tax.toString());
-//                goods.setDiscountedPrice(retailPrice.subtract(discountEntity.getActivityPrice()).setScale(2,BigDecimal.ROUND_HALF_UP));
                 goods.setActivity("打折");
             }
         }
@@ -1709,10 +1696,6 @@ public class GoodsServiceImpl implements GoodsService {
                 goods.setActualPaymentAmount(dailyActivitiesEntity.getActivityPrice());
                 goods.setRetailPrice(dailyActivitiesEntity.getActivityPrice());
 
-                // TODO 税费需要修改
-                tax = goodsRate.multiply(dailyActivitiesEntity.getActivityPrice().divide(new BigDecimal(1).add(goodsRate),2,RoundingMode.HALF_DOWN)).setScale(2,RoundingMode.HALF_DOWN) ;
-                goods.setGoodstaxes(tax.toString());
-//                goods.setDiscountedPrice(retailPrice.subtract(dailyActivitiesEntity.getActivityPrice()).setScale(2,BigDecimal.ROUND_HALF_UP));
                 goods.setActivity("日常活动");
 
             }
@@ -1730,15 +1713,16 @@ public class GoodsServiceImpl implements GoodsService {
                 goods.setActualPaymentAmount(promotionEntity.getActivityPrice());
                 goods.setRetailPrice(promotionEntity.getActivityPrice());
 
-                // TODO 税费需要修改
-                tax = goodsRate.multiply(promotionEntity.getActivityPrice().divide(new BigDecimal(1).add(goodsRate),2,RoundingMode.HALF_DOWN)).setScale(2,RoundingMode.HALF_DOWN) ;
-                goods.setGoodstaxes(tax.toString());
-//                goods.setDiscountedPrice(retailPrice.subtract(promotionEntity.getActivityPrice()).setScale(2,BigDecimal.ROUND_HALF_UP));
                 goods.setActivity("临时促销");
 
             }
         }
 
+        // 计算税费
+        GoodsEntity goodsEntity = goodsDao.queryByBarcodeAndSku(prodBarcode, goods.getGoodsSn());
+        BigDecimal tax = CalculateTax.calculateFinalTax(goodsEntity,goods.getActualPaymentAmount(),this);
+        goods.setGoodstaxes(tax.toString());
+
 
         skuActivitiesMap.put("goods",goods);
         return skuActivitiesMap;
@@ -1901,5 +1885,21 @@ public class GoodsServiceImpl implements GoodsService {
         }
     }
 
+    @Override
+    public void updateTaxErrorRecord(TaxErrorRecordEntity taxErrorRecordEntity) {
+        taxErrorRecordDao.update(taxErrorRecordEntity);
+    }
+
+    @Override
+    public void insertTaxErrorRecord(TaxErrorRecordEntity taxErrorRecordEntity) {
+        taxErrorRecordDao.save(taxErrorRecordEntity);
+
+    }
+
+    @Override
+    public void updateByEntity(GoodsEntity updateGoods) {
+        goodsDao.update(updateGoods);
+    }
+
 
 }

+ 59 - 0
kmall-admin/src/main/java/com/kmall/admin/service/impl/TaxErrorRecordServiceImpl.java

@@ -0,0 +1,59 @@
+package com.kmall.admin.service.impl;
+
+import com.kmall.admin.dao.TaxErrorRecordDao;
+import com.kmall.admin.entity.TaxErrorRecordEntity;
+import com.kmall.admin.service.TaxErrorRecordService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 税款异常记录表Service实现类
+ *
+ * @author emato
+ * @email admin@qhdswl.com
+ * @date 2020-12-18 14:37:40
+ */
+@Service("taxErrorRecordService")
+public class TaxErrorRecordServiceImpl implements TaxErrorRecordService {
+    @Autowired
+    private TaxErrorRecordDao taxErrorRecordDao;
+
+    @Override
+    public TaxErrorRecordEntity queryObject(Integer id) {
+        return taxErrorRecordDao.queryObject(id);
+    }
+
+    @Override
+    public List<TaxErrorRecordEntity> queryList(Map<String, Object> map) {
+        return taxErrorRecordDao.queryList(map);
+    }
+
+    @Override
+    public int queryTotal(Map<String, Object> map) {
+        return taxErrorRecordDao.queryTotal(map);
+    }
+
+    @Override
+    public int save(TaxErrorRecordEntity taxErrorRecord) {
+        return taxErrorRecordDao.save(taxErrorRecord);
+    }
+
+    @Override
+    public int update(TaxErrorRecordEntity taxErrorRecord) {
+        return taxErrorRecordDao.update(taxErrorRecord);
+    }
+
+    @Override
+    public int delete(Integer id) {
+        return taxErrorRecordDao.delete(id);
+    }
+
+    @Override
+    public int deleteBatch(Integer[]ids) {
+        return taxErrorRecordDao.deleteBatch(ids);
+    }
+}

+ 160 - 49
kmall-admin/src/main/java/com/kmall/admin/utils/CalculateTax.java

@@ -1,9 +1,13 @@
 package com.kmall.admin.utils;
 
 
+import com.kmall.admin.dao.GoodsDao;
+import com.kmall.admin.dao.TaxErrorRecordDao;
 import com.kmall.admin.dto.GoodsDetailsDto;
 import com.kmall.admin.dto.GoodsDto;
 import com.kmall.admin.entity.GoodsEntity;
+import com.kmall.admin.entity.TaxErrorRecordEntity;
+import com.kmall.admin.service.GoodsService;
 import com.kmall.manager.manager.express.sf.ServiceException;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -11,10 +15,7 @@ import org.slf4j.LoggerFactory;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -29,6 +30,8 @@ public class CalculateTax {
 
     private static Map<String,BigDecimal> hsCodeMap = new HashMap<String,BigDecimal>();
 
+    private static BigDecimal consumerGoodsRate = new BigDecimal("0.2306");
+    private static BigDecimal noConsumerGoodsRate = new BigDecimal("0.091");
 
     /*
     cus_goods_code	计税方式
@@ -275,20 +278,13 @@ public class CalculateTax {
        * 1.2.3 总计订单全部明细商品消费税;
      * @return
      */
-    public static BigDecimal calculateFinalTax(GoodsEntity goodsEntity,BigDecimal retailPrice){
+    public static BigDecimal calculateFinalTax(GoodsEntity goods, BigDecimal retailPrice, GoodsService goodsService){
 
-        GoodsEntity goods  = null;
-        GoodsDetailsDto goodsDetailsDto = null;
         // 判断商品的海关商品编码是否是在特殊化妆品里面
         // 海关商品编码
         String hsCode = goods.getHsCode();
-
-
         // 商品税率
         BigDecimal goodsRate = goods.getGoodsRate();
-
-
-
         if(hsCodeMap.containsKey(hsCode)){
             String cusGoodsName = goods.getHsCodeName();
             // 法1
@@ -297,61 +293,176 @@ public class CalculateTax {
             BigDecimal qty2 = goods.getLegalUnit2Qty();
             // 阈值
             BigDecimal cosmThresholdValue = goods.getCosmThresholdValue();
-            BigDecimal unit1Price = null;
-            BigDecimal unit2Price = null;
-            // 根据税后价计算出税前价
-            BigDecimal productUnitPrice = retailPrice ; // TODO 需要得到公式计算出税前价
-
-            if (StringUtils.isNotBlank(cusGoodsName) && (cusGoodsName.contains("“片”") || cusGoodsName.contains("“张”") || cusGoodsName.contains("片") || cusGoodsName.contains("张"))) {
-                //片、张的单价
-                if (qty2 != null) {
-                    // 计算税额是否达到阈值
-                    unit2Price = productUnitPrice.divide(qty2, 5, BigDecimal.ROUND_HALF_UP);
-                }
-            } else {
-                //毫升、克的单价
-                if (qty1 != null) {
-                    BigDecimal gramOrMl = qty1.multiply(new BigDecimal(1000));
-                    unit1Price = productUnitPrice.divide(gramOrMl, 5, BigDecimal.ROUND_HALF_UP);
-                }
-            }
 
-            // 每单位价格
-            // 如果有片、张的单价,按片、张;如果没有则按毫升、克
-            BigDecimal gramOrMlUnitPrice = (unit2Price != null) ? unit2Price : unit1Price;
+
+            BigDecimal gramOrMlUnitPrice = getUnitPrice(retailPrice, goodsRate, cusGoodsName, qty1, qty2);
 
             //获取化妆品阀值
             if (cosmThresholdValue != null && cosmThresholdValue.compareTo(BigDecimal.ZERO) > 0) {
                 if (gramOrMlUnitPrice != null) {
                     //完税法定单位单价大于阈值采用第一档消费税率,否则消费税率为0
                     if (gramOrMlUnitPrice.compareTo(cosmThresholdValue) >= 0) {
-                        goodsRate = new BigDecimal("0.2306");
-                        return goodsRate.multiply(retailPrice
-                                .divide(new BigDecimal(1).add(goodsRate),2, RoundingMode.HALF_DOWN))
-                                .setScale(2,RoundingMode.HALF_DOWN) ;
+                        // 征收消费税,此时判断税率是否为23.06,如果进入if,则是23.06  如果进了else 则当前税率为9.1
+                        if(goodsRate.compareTo(consumerGoodsRate) == 0){
+                            return getTax(retailPrice, goodsRate);
+                        }else{
+                            // 如果不是。重新用23.06计算一次
+                            gramOrMlUnitPrice = getUnitPrice(retailPrice, consumerGoodsRate, cusGoodsName, qty1, qty2);
+                            if (gramOrMlUnitPrice.compareTo(cosmThresholdValue) >= 0) {
+                                // 如果用23.06去计算,还是大于阈值,那就是用23.06去计税
+                                return getTax(retailPrice, consumerGoodsRate);
+                            }else{
+                                BigDecimal tax = getFinalTax(goods, retailPrice, goodsService, cusGoodsName, qty1, qty2);
+                                return tax;
+                            }
+                        }
+
                     } else {
-                        goodsRate = new BigDecimal("0.091");
-                        return goodsRate.multiply(retailPrice
-                                .divide(new BigDecimal(1).add(goodsRate),2, RoundingMode.HALF_DOWN))
-                                .setScale(2,RoundingMode.HALF_DOWN) ;
+
+                        // 不征收消费税,判断税率是否是9.1  如果进了if,则是9.1 ,如果进了else,则当前税率是23.06
+                        if(goodsRate.compareTo(noConsumerGoodsRate) == 0){
+                            return getTax(retailPrice, goodsRate);
+                        }else{
+
+                            // 如果不是,重新用0.091计算一次
+                            gramOrMlUnitPrice = getUnitPrice(retailPrice, noConsumerGoodsRate, cusGoodsName, qty1, qty2);
+                            if (gramOrMlUnitPrice.compareTo(cosmThresholdValue) >= 0) {
+                                BigDecimal tax = getFinalTax(goods, retailPrice, goodsService, cusGoodsName, qty1, qty2);
+                                return tax;
+
+                            }else{
+                                return getTax(retailPrice, noConsumerGoodsRate);
+                            }
+
+                        }
                     }
                 } else {
-                    String message = "【" + goodsEntity.getSku() + "】缺少法定单价";
+                    String message = "【" + goods.getSku() + "】缺少法定单价";
                     logger.error(message);
-                    throw new ServiceException(message);
+                    // 没有法一法二,记录起来
+                    TaxErrorRecordEntity taxErrorRecordEntity = new TaxErrorRecordEntity();
+                    taxErrorRecordEntity.setSku(goods.getGoodsSn());
+                    taxErrorRecordEntity.setMoney(retailPrice.toString());
+                    taxErrorRecordEntity.setHandle("0");
+                    taxErrorRecordEntity.setGoodsRate(goodsRate.toString());
+                    taxErrorRecordEntity.setErrorTime(new Date());
+                    goodsService.insertTaxErrorRecord(taxErrorRecordEntity);
+
+                    // 一般走不到这里,但是为了做个保险,还是要这个
+                    return getTax(retailPrice, goodsRate);
                 }
             }
+            // 特殊化妆品但是规格型号符合不上,记录起来
+            TaxErrorRecordEntity taxErrorRecordEntity = new TaxErrorRecordEntity();
+            taxErrorRecordEntity.setSku(goods.getGoodsSn());
+            taxErrorRecordEntity.setMoney(retailPrice.toString());
+            taxErrorRecordEntity.setHandle("0");
+            taxErrorRecordEntity.setGoodsRate(goodsRate.toString());
+            taxErrorRecordEntity.setErrorTime(new Date());
+            goodsService.insertTaxErrorRecord(taxErrorRecordEntity);
+
             // 一般走不到这里,但是为了做个保险,还是要这个
-            return goodsRate.multiply(retailPrice
-                    .divide(new BigDecimal(1).add(goodsRate),2, RoundingMode.HALF_DOWN))
-                    .setScale(2,RoundingMode.HALF_DOWN) ;
+            return getTax(retailPrice, goodsRate);
 
         }else{
             // 该商品不是特殊海关商品编码,直接用里面的税率进行计算
-            return goodsRate.multiply(retailPrice
-                    .divide(new BigDecimal(1).add(goodsRate),2, RoundingMode.HALF_DOWN))
-                    .setScale(2,RoundingMode.HALF_DOWN) ;
+            return getTax(retailPrice, goodsRate);
+
+        }
+    }
+
+
+
+    private static BigDecimal getFinalTax(GoodsEntity goods, BigDecimal retailPrice, GoodsService goodsService, String cusGoodsName, BigDecimal qty1, BigDecimal qty2) {
+        BigDecimal goodsRate;
+        // 当使用0.091的时候,发现要收消费税。当使用0.2306的时候,不收消费税
+        // 然后分别用两种计税方式去算税前价,然后算税费,最后去一个更接近税后价的来计算
+        BigDecimal noConsumerTaxPrice = retailPrice.divide(BigDecimal.ONE.add(noConsumerGoodsRate),3,RoundingMode.HALF_UP).setScale(2,RoundingMode.HALF_UP);
+        BigDecimal tax1 = noConsumerTaxPrice.multiply(consumerGoodsRate).setScale(2,RoundingMode.HALF_UP);
+        BigDecimal finalPrice1 = tax1.add(noConsumerTaxPrice);
+
+
+        BigDecimal consumerTaxPrice = retailPrice.divide(BigDecimal.ONE.add(consumerGoodsRate),3,RoundingMode.HALF_UP).setScale(2,RoundingMode.HALF_UP);
+        BigDecimal tax2 = consumerTaxPrice.multiply(noConsumerGoodsRate).setScale(2,RoundingMode.HALF_UP);
+        BigDecimal finalPrice2 = tax2.add(consumerTaxPrice);
+
+        // 比较两个价格哪个比较接近税后价
+        BigDecimal abs1 = finalPrice1.subtract(retailPrice).abs();
+        BigDecimal abs2 = finalPrice2.subtract(retailPrice).abs();
+
+        BigDecimal tax ;
+        if(abs1.compareTo(abs2) > 0){
+            goodsRate = consumerGoodsRate;
+            tax = tax2;
+        }else{
+            goodsRate = noConsumerGoodsRate;
+            tax = tax1;
+        }
+
+        // 如果用23.06去计算,小于阈值,则证明当前商品的价格有问题,需要记录起来 当前商品的sku,当前商品税率,异常时间
+        // 存储异常sku , 并修改税率
+        TaxErrorRecordEntity taxErrorRecordEntity = new TaxErrorRecordEntity();
+        taxErrorRecordEntity.setSku(goods.getGoodsSn());
+        taxErrorRecordEntity.setMoney(retailPrice.toString());
+        taxErrorRecordEntity.setHandle("0");
+        taxErrorRecordEntity.setGoodsRate(goodsRate.toString());
+        taxErrorRecordEntity.setErrorTime(new Date());
+        goodsService.insertTaxErrorRecord(taxErrorRecordEntity);
+
+//        GoodsEntity updateGoods = new GoodsEntity();
+//        updateGoods.setGoodsRate(goodsRate);
+//        updateGoods.setId(goods.getId());
+//        goodsService.updateByEntity(updateGoods);
+        return tax;
+    }
+
+
+    /**
+     * 根据税率、税后价,计算出税
+     * @param retailPrice 税后价
+     * @param goodsRate 税率
+     * @return
+     */
+    private static BigDecimal getTax(BigDecimal retailPrice, BigDecimal goodsRate) {
+        return goodsRate.multiply(retailPrice
+                .divide(new BigDecimal(1).add(goodsRate), 2, RoundingMode.HALF_DOWN))
+                .setScale(2, RoundingMode.HALF_DOWN);
+    }
+
+
+    /**
+     * 计算出特殊化妆品的单价
+     * @param retailPrice 税后价
+     * @param goodsRate 税率
+     * @param cusGoodsName 规格名称
+     * @param qty1 法一
+     * @param qty2 法二
+     * @return
+     */
+    private static BigDecimal getUnitPrice(BigDecimal retailPrice, BigDecimal goodsRate, String cusGoodsName, BigDecimal qty1, BigDecimal qty2) {
+        BigDecimal unit1Price = null;
+        BigDecimal unit2Price = null;
 
+        // 根据税后价计算出税前价
+        BigDecimal productUnitPrice = retailPrice
+                .divide(new BigDecimal(1).add(goodsRate),2, RoundingMode.HALF_DOWN) ; // TODO 需要得到公式计算出税前价
+
+        if (StringUtils.isNotBlank(cusGoodsName) && (cusGoodsName.contains("“片”") || cusGoodsName.contains("“张”") || cusGoodsName.contains("片") || cusGoodsName.contains("张"))) {
+            //片、张的单价
+            if (qty2 != null) {
+                // 计算税额是否达到阈值
+                unit2Price = productUnitPrice.divide(qty2, 5, BigDecimal.ROUND_HALF_UP);
+            }
+        } else {
+            //毫升、克的单价
+            if (qty1 != null) {
+                BigDecimal gramOrMl = qty1.multiply(new BigDecimal(1000));
+                unit1Price = productUnitPrice.divide(gramOrMl, 5, BigDecimal.ROUND_HALF_UP);
+            }
         }
+        // 每单位价格
+        // 如果有片、张的单价,按片、张;如果没有则按毫升、克
+        BigDecimal gramOrMlUnitPrice = (unit2Price != null) ? unit2Price : unit1Price;
+        return gramOrMlUnitPrice;
     }
 }

+ 1 - 1
kmall-admin/src/main/resources/logback.xml

@@ -37,7 +37,7 @@ debug:当此属性设置为true时,将打印出logback内部日志信息,
         -->
         <encoder>
             <pattern>${STD_CONSOLE_LOG_PATTERN}</pattern>
-            <charset>GBK</charset>
+            <charset>UTF-8</charset>
         </encoder>
     </appender>
 

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

@@ -2034,6 +2034,7 @@
     <select id="queryExportSystemFormatList" resultType="com.kmall.admin.dto.SystemFormatDto">
         SELECT distinct
         o.id,
+        g.goods_id,
         o.order_sn as receiptNo,
         u.username as cashRegisterNo,
         o.pay_time as timeStampDetails,

+ 117 - 0
kmall-admin/src/main/resources/mybatis/mapper/TaxErrorRecordDao.xml

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.kmall.admin.dao.TaxErrorRecordDao">
+
+    <resultMap type="com.kmall.admin.entity.TaxErrorRecordEntity" id="taxErrorRecordMap">
+        <result property="id" column="id"/>
+        <result property="sku" column="sku"/>
+        <result property="goodsRate" column="goods_rate"/>
+        <result property="money" column="money"/>
+        <result property="errorTime" column="error_time"/>
+        <result property="handle" column="handle"/>
+        <result property="moderSn" column="moder_sn"/>
+        <result property="modTime" column="mod_time"/>
+        <result property="tstm" column="tstm"/>
+    </resultMap>
+
+	<select id="queryObject" resultType="com.kmall.admin.entity.TaxErrorRecordEntity">
+		select
+			`id`,
+			`sku`,
+			`goods_rate`,
+			`money`,
+			`error_time`,
+			`handle`,
+			`moder_sn`,
+			`mod_time`,
+			`tstm`
+		from mall_tax_error_record
+		where id = #{id}
+	</select>
+
+	<select id="queryList" resultType="com.kmall.admin.entity.TaxErrorRecordEntity">
+		select
+    		`id`,
+    		`sku`,
+    		`goods_rate`,
+    		`money`,
+    		`error_time`,
+    		`handle`,
+    		`moder_sn`,
+    		`mod_time`,
+    		`tstm`
+		from mall_tax_error_record
+		WHERE 1=1
+		<if test="name != null and name.trim() != ''">
+			AND name LIKE concat('%',#{name},'%')
+		</if>
+        <choose>
+            <when test="sidx != null and sidx.trim() != ''">
+                order by ${sidx} ${order}
+            </when>
+			<otherwise>
+                order by id desc
+			</otherwise>
+        </choose>
+		<if test="offset != null and limit != null">
+			limit #{offset}, #{limit}
+		</if>
+	</select>
+
+ 	<select id="queryTotal" resultType="int">
+		select count(*) from mall_tax_error_record
+		WHERE 1=1
+        <if test="name != null and name.trim() != ''">
+            AND name LIKE concat('%',#{name},'%')
+        </if>
+	</select>
+
+	<insert id="save" parameterType="com.kmall.admin.entity.TaxErrorRecordEntity" useGeneratedKeys="true" keyProperty="id">
+		insert into mall_tax_error_record(
+			`sku`,
+			`goods_rate`,
+			`money`,
+			`error_time`,
+			`handle`,
+			`moder_sn`,
+			`mod_time`,
+			`tstm`)
+		values(
+			#{sku},
+			#{goodsRate},
+			#{money},
+			#{errorTime},
+			#{handle},
+			#{moderSn},
+			#{modTime},
+			#{tstm})
+	</insert>
+
+	<update id="update" parameterType="com.kmall.admin.entity.TaxErrorRecordEntity">
+		update mall_tax_error_record
+		<set>
+			<if test="sku != null">`sku` = #{sku}, </if>
+			<if test="goodsRate != null">`goods_rate` = #{goodsRate}, </if>
+			<if test="money != null">`money` = #{money}, </if>
+			<if test="errorTime != null">`error_time` = #{errorTime}, </if>
+			<if test="handle != null">`handle` = #{handle}, </if>
+			<if test="moderSn != null">`moder_sn` = #{moderSn}, </if>
+			<if test="modTime != null">`mod_time` = #{modTime}, </if>
+			<if test="tstm != null">`tstm` = #{tstm}</if>
+		</set>
+		where id = #{id}
+	</update>
+
+	<delete id="delete">
+		delete from mall_tax_error_record where id = #{value}
+	</delete>
+
+	<delete id="deleteBatch">
+		delete from mall_tax_error_record where id in
+		<foreach item="id" collection="array" open="(" separator="," close=")">
+			#{id}
+		</foreach>
+	</delete>
+
+</mapper>

+ 72 - 0
kmall-admin/src/main/webapp/WEB-INF/page/shop/taxerrorrecord.html

@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>税款异常记录表</title>
+    #parse("sys/header.html")
+</head>
+<body>
+<div id="rrapp" v-cloak>
+	<div v-show="showList">
+        <Row :gutter="16">
+            <div class="search-group">
+                <i-col span="4">
+                    <i-input v-model="q.name" @on-enter="query" placeholder="名称"/>
+                </i-col>
+                <i-button @click="query">查询</i-button>
+                <i-button @click="reloadSearch">重置</i-button>
+            </div>
+            <div class="buttons-group">
+                #if($shiro.hasPermission("taxerrorrecord:save"))
+                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
+                #end
+                #if($shiro.hasPermission("taxerrorrecord:update"))
+                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
+                #end
+                #if($shiro.hasPermission("taxerrorrecord:delete"))
+                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
+                #end
+            </div>
+        </Row>
+	    <table id="jqGrid"></table>
+	    <div id="jqGridPager"></div>
+    </div>
+
+    <Card v-show="!showList">
+        <p slot="title">{{title}}</p>
+		<i-form ref="formValidate" :model="taxErrorRecord" :rules="ruleValidate" :label-width="80">
+            <Form-item label="料件号" prop="sku">
+                <i-input v-model="taxErrorRecord.sku" placeholder="料件号"/>
+            </Form-item>
+            <Form-item label="税率" prop="goodsRate">
+                <i-input v-model="taxErrorRecord.goodsRate" placeholder="税率"/>
+            </Form-item>
+            <Form-item label="金额" prop="money">
+                <i-input v-model="taxErrorRecord.money" placeholder="金额"/>
+            </Form-item>
+            <Form-item label="异常发生时间" prop="errorTime">
+                <i-input v-model="taxErrorRecord.errorTime" placeholder="异常发生时间"/>
+            </Form-item>
+            <Form-item label="是否修改过" prop="handle">
+                <i-input v-model="taxErrorRecord.handle" placeholder="是否修改过"/>
+            </Form-item>
+            <Form-item label="修改人编号" prop="moderSn">
+                <i-input v-model="taxErrorRecord.moderSn" placeholder="修改人编号"/>
+            </Form-item>
+            <Form-item label="修改时间" prop="modTime">
+                <i-input v-model="taxErrorRecord.modTime" placeholder="修改时间"/>
+            </Form-item>
+            <Form-item label="时间戳" prop="tstm">
+                <i-input v-model="taxErrorRecord.tstm" placeholder="时间戳"/>
+            </Form-item>
+            <Form-item>
+                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
+                <i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button>
+                <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
+            </Form-item>
+        </i-form>
+	</Card>
+</div>
+
+<script src="${rc.contextPath}/js/shop/taxerrorrecord.js?_${date.systemTime}"></script>
+</body>
+</html>

+ 146 - 0
kmall-admin/src/main/webapp/js/shop/taxerrorrecord.js

@@ -0,0 +1,146 @@
+$(function () {
+    $("#jqGrid").jqGrid({
+        url: '../taxerrorrecord/list',
+        datatype: "json",
+        colModel: [
+			{label: 'id', name: 'id', index: 'id', key: true, hidden: true},
+			{label: '料件号', name: 'sku', index: 'sku', width: 80},
+			{label: '税率', name: 'goodsRate', index: 'goods_rate', width: 80},
+			{label: '金额', name: 'money', index: 'money', width: 80},
+			{label: '异常发生时间', name: 'errorTime', index: 'error_time', width: 80},
+			{label: '是否修改过', name: 'handle', index: 'handle', width: 80},
+			{label: '修改人编号', name: 'moderSn', index: 'moder_sn', width: 80},
+			{label: '修改时间', name: 'modTime', index: 'mod_time', width: 80},
+			{label: '时间戳', name: 'tstm', index: 'tstm', width: 80}],
+		viewrecords: true,
+        height: 550,
+        rowNum: 10,
+        rowList: [10, 30, 50],
+        rownumbers: true,
+        rownumWidth: 25,
+        autowidth: true,
+        multiselect: true,
+        pager: "#jqGridPager",
+        jsonReader: {
+            root: "page.list",
+            page: "page.currPage",
+            total: "page.totalPage",
+            records: "page.totalCount"
+        },
+        prmNames: {
+            page: "page",
+            rows: "limit",
+            order: "order"
+        },
+        gridComplete: function () {
+            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
+        }
+    });
+});
+
+let vm = new Vue({
+	el: '#rrapp',
+	data: {
+        showList: true,
+        title: null,
+		taxErrorRecord: {},
+		ruleValidate: {
+			name: [
+				{required: true, message: '名称不能为空', trigger: 'blur'}
+			]
+		},
+		q: {
+		    name: ''
+		}
+	},
+	methods: {
+		query: function () {
+			vm.reload();
+		},
+		add: function () {
+			vm.showList = false;
+			vm.title = "新增";
+			vm.taxErrorRecord = {};
+		},
+		update: function (event) {
+            let id = getSelectedRow();
+			if (id == null) {
+				return;
+			}
+			vm.showList = false;
+            vm.title = "修改";
+
+            vm.getInfo(id)
+		},
+		saveOrUpdate: function (event) {
+            let url = vm.taxErrorRecord.id == null ? "../taxerrorrecord/save" : "../taxerrorrecord/update";
+			$.ajax({
+				type: "POST",
+			    url: url,
+			    contentType: "application/json",
+			    data: JSON.stringify(vm.taxErrorRecord),
+                success: function (r) {
+                    if (r.code === 0) {
+                        alert('操作成功', function (index) {
+                            vm.reload();
+                        });
+                    } else {
+                        alert(r.msg);
+                    }
+                }
+			});
+		},
+		del: function (event) {
+            let ids = getSelectedRows();
+			if (ids == null){
+				return;
+			}
+
+			confirm('确定要删除选中的记录?', function () {
+				$.ajax({
+					type: "POST",
+				    url: "../taxerrorrecord/delete",
+				    contentType: "application/json",
+				    data: JSON.stringify(ids),
+				    success: function (r) {
+						if (r.code == 0) {
+							alert('操作成功', function (index) {
+								$("#jqGrid").trigger("reloadGrid");
+							});
+						} else {
+							alert(r.msg);
+						}
+					}
+				});
+			});
+		},
+		getInfo: function(id){
+			$.get("../taxerrorrecord/info/"+id, function (r) {
+                vm.taxErrorRecord = r.taxErrorRecord;
+            });
+		},
+        reloadSearch: function() {
+            vm.q = {
+                name: ''
+            }
+            vm.reload();
+		},
+		reload: function (event) {
+			vm.showList = true;
+            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
+			$("#jqGrid").jqGrid('setGridParam', {
+                postData: {'name': vm.q.name},
+                page: page
+            }).trigger("reloadGrid");
+            vm.handleReset('formValidate');
+		},
+        handleSubmit: function (name) {
+            handleSubmitValidate(this, name, function () {
+                vm.saveOrUpdate()
+            });
+        },
+        handleReset: function (name) {
+            handleResetForm(this, name);
+        }
+	}
+});