From 757d9c5adb245edc49e7e3c3a56893aeb1f61518 Mon Sep 17 00:00:00 2001 From: cun-nan <19819293608@163.com> Date: Tue, 14 Nov 2023 19:00:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E9=93=B6=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fuyou/service/MerchantConfigService.java | 5 + .../fuyou/service/impl/FyPayServiceImpl.java | 29 +- .../impl/MerchantConfigServiceImpl.java | 13 + .../service/impl/OilConfigServiceImpl.java | 3 + .../controller/CreditUnitController.java | 35 + .../order/controller/HangBillController.java | 81 ++ .../business/order/entity/CreditUnit.java | 58 ++ .../fuint/business/order/entity/HangBill.java | 151 +-- .../order/mapper/CreditUnitMapper.java | 10 + .../business/order/mapper/HangBillMapper.java | 27 + .../order/mapper/xml/HangBillMapper.xml | 53 + .../order/service/CreditUnitService.java | 24 + .../order/service/HangBillService.java | 41 +- .../service/impl/CreditUnitServiceImpl.java | 27 + .../service/impl/HangBillServiceImpl.java | 138 ++- .../fuint/business/order/vo/HangBillVo.java | 10 + fuintCashierWeb/src/api/cashier/creditunit.js | 19 + fuintCashierWeb/src/api/cashier/hangbill.js | 44 + .../views/cashier/NewComponents/credit.vue | 975 ++++++++++++++---- 19 files changed, 1422 insertions(+), 321 deletions(-) create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/CreditUnitController.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/controller/HangBillController.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/CreditUnit.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/CreditUnitMapper.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/HangBillMapper.xml create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/CreditUnitService.java create mode 100644 fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/CreditUnitServiceImpl.java create mode 100644 fuintCashierWeb/src/api/cashier/creditunit.js create mode 100644 fuintCashierWeb/src/api/cashier/hangbill.js diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java index 55c78fc14..869ed4e66 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/MerchantConfigService.java @@ -35,6 +35,11 @@ public interface MerchantConfigService extends IService { */ public MerchantConfig selectMerchById(int id); + /** + * 将所有的使用1改为0 + */ + public void updateMerchOrter(); + /** * 修改商户使用状态 * @param merchantConfig diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java index dea5035a4..7f03e35f7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java @@ -13,9 +13,11 @@ import com.fuint.api.fuyou.util.Utils; import com.fuint.business.marketingActivity.cardFule.service.CardFuelRecordService; import com.fuint.business.marketingActivity.cardValue.service.CardValueRecordService; import com.fuint.business.order.entity.CashierOrder; +import com.fuint.business.order.entity.HangBill; import com.fuint.business.order.entity.LJOrder; import com.fuint.business.order.entity.OilOrder; import com.fuint.business.order.service.CashierOrderService; +import com.fuint.business.order.service.HangBillService; import com.fuint.business.order.service.LJOrderService; import com.fuint.business.order.service.OilOrderService; import io.swagger.models.auth.In; @@ -83,14 +85,14 @@ public class FyPayServiceImpl implements FyPayService { timer.schedule(new TimerTask() { @Override public void run() { - try { - Map orderQueryRes = queryOrder(map1); - if(!orderQueryRes.get("msg").equals("unpaid")){ - timer.cancel(); - } - } catch (Exception e) { - throw new RuntimeException(e); - } + try { + Map orderQueryRes = queryOrder(map1); + if(!orderQueryRes.get("msg").equals("unpaid")){ + timer.cancel(); + } + } catch (Exception e) { + throw new RuntimeException(e); + } } //定时器 立即开始 0.5s一次 }, 0, 500); @@ -102,6 +104,8 @@ public class FyPayServiceImpl implements FyPayService { @Autowired private MerchantConfigService merchantConfigService; + @Autowired + private HangBillService hangBillService; @Override public Map queryOrder(Map map1) throws Exception { @@ -140,6 +144,7 @@ public class FyPayServiceImpl implements FyPayService { LJOrder goodsOrder = goodsOrderService.selectGoodsOrder(orderNo); CashierOrder cashierOrder = cashierOrderService.selectCashierOrder(orderNo); MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1"); + HangBill hangBill = hangBillService.selectHangBillByOrderNo(orderNo); Date date = new Date(); if (reqMap.get("trans_stat").equals("SUCCESS")){ if (!ObjectUtil.isEmpty(oilOrder)){ @@ -152,6 +157,10 @@ public class FyPayServiceImpl implements FyPayService { if (!ObjectUtil.isEmpty(cashierOrder)){ cashierOrder.setStatus("paid"); } + if (!ObjectUtil.isEmpty(hangBill)){ + hangBill.setPayStatus("paid"); + hangBillService.updateHangBills(hangBill,allAmount); + } if (ArrayUtil.isEmpty(list)){ for (OilOrder order : list) { order.setOrderStatus("paid"); @@ -185,6 +194,10 @@ public class FyPayServiceImpl implements FyPayService { if (!ObjectUtil.isEmpty(cashierOrder)){ cashierOrder.setStatus("payFail"); } + if (!ObjectUtil.isEmpty(hangBill)){ + hangBill.setPayStatus("payFail"); + hangBillService.updateById(hangBill); + } if (!ArrayUtil.isEmpty(list)){ for (OilOrder order : list) { order.setOrderStatus("payFail"); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java index cdc67d54d..a6e3df6b7 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/MerchantConfigServiceImpl.java @@ -48,6 +48,19 @@ public class MerchantConfigServiceImpl extends ServiceImpl(); + queryWrapper.eq("is_use","1"); + List list = baseMapper.selectList(queryWrapper); + if (list.size()>0){ + for (MerchantConfig merchantConfig : list) { + merchantConfig.setIsUse("0"); + this.updateMerch(merchantConfig); + } + } + } + @Override public int updateMerch(MerchantConfig merchantConfig) { int row = baseMapper.updateById(merchantConfig); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java index 4787f848c..5fb5eac83 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/OilConfigServiceImpl.java @@ -50,6 +50,9 @@ public class OilConfigServiceImpl extends ServiceImpl list = hangBillService.selectHangBillList(page,hangBillVo); + return getSuccessResult(list); + } + + /** + * 查询所有挂账信息 + * @return + */ + @GetMapping("/hangBills") + public ResponseObject hangBills(){ + return getSuccessResult(hangBillService.selectHangBills()); + } + + /** + * 根据id查询挂账信息 + * @param id + * @return + */ + @GetMapping("/{id}") + public ResponseObject info(@PathVariable Integer id){ + HangBillVo hangBillVo = hangBillService.selectHangBillById(id); + return getSuccessResult(hangBillVo); + } + + /** + * 添加挂账记录信息 + * @param hangBill + * @return + */ + @PostMapping + public ResponseObject add(@Validated @RequestBody HangBill hangBill){ + return getSuccessResult(hangBillService.insertHangBill(hangBill)); + } + + /** + * 归还挂账记录信息,并收款 + * @param map + * @return + */ + @PutMapping + public ResponseObject edit(@Validated @RequestBody Map map){ + int row = hangBillService.updateHangBill(map); + return getSuccessResult(row); + } +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/CreditUnit.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/CreditUnit.java new file mode 100644 index 000000000..6a80bc657 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/CreditUnit.java @@ -0,0 +1,58 @@ +package com.fuint.business.order.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fuint.framework.entity.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.io.Serializable; + +/** + * 挂账单位信息表(CreditUnit)实体类 + * + * @author makejava + * @since 2023-11-14 10:45:00 + */ +@Data +@TableName("credit_unit") +@ApiModel(value = "CreditUnit对象", description = "挂账单位信息表") +public class CreditUnit extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + /** + * 主键 + */ + @ApiModelProperty("自增ID") + @TableId(value = "ID", type = IdType.AUTO) + private Integer id; + /** + * 单位名称 + */ + private String unitName; + /** + * 挂账人 + */ + private String personCredit; + /** + * 联系电话 + */ + private String contactMobile; + /** + * 挂账额度 + */ + private Double creditLimit; + /** + * 单据备注 + */ + private String remark; + /** + * 单位状态:启用禁用 + */ + private String status; + +} + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HangBill.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HangBill.java index 1af35fdce..28038a820 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HangBill.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/entity/HangBill.java @@ -30,26 +30,22 @@ public class HangBill extends BaseEntity implements Serializable { * 店铺id */ private Integer storeId; + /** + * 挂账单位id + */ + private Integer creditUnitId; /** * 订单号 */ private String orderNo; - /** - * 单位名称 - */ - private String unitName; - /** - * 挂账人 - */ - private String personCredit; - /** - * 联系电话 - */ - private String contactMobile; /** * 订单状态:0未归还,1已归还 */ private String status; + /** + * 支付状态:已支付,未支付,支付失败 + */ + private String payStatus; /** * 归还状态:0挂账,1归还 */ @@ -57,7 +53,15 @@ public class HangBill extends BaseEntity implements Serializable { /** * 挂账金额 */ - private String amount; + private Double amount; + /** + * 已还金额 + */ + private Double repaidAmount; + /** + * 未还金额 + */ + private Double outstandAmount; /** * 操作员工id */ @@ -66,127 +70,6 @@ public class HangBill extends BaseEntity implements Serializable { * 单据备注 */ private String remark; - /** - * 创建时间 - */ - private Date createTime; - /** - * 更新时间 - */ - private Date updateTime; - /** - * 创建用户 - */ - private String createBy; - /** - * 修改用户 - */ - private String updateBy; - - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getOrderNo() { - return orderNo; - } - - public void setOrderNo(String orderNo) { - this.orderNo = orderNo; - } - - public String getUnitName() { - return unitName; - } - - public void setUnitName(String unitName) { - this.unitName = unitName; - } - - public String getPersonCredit() { - return personCredit; - } - - public void setPersonCredit(String personCredit) { - this.personCredit = personCredit; - } - - public String getContactMobile() { - return contactMobile; - } - - public void setContactMobile(String contactMobile) { - this.contactMobile = contactMobile; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public String getAmount() { - return amount; - } - - public void setAmount(String amount) { - this.amount = amount; - } - - public Integer getStaffId() { - return staffId; - } - - public void setStaffId(Integer staffId) { - this.staffId = staffId; - } - - public String getRemark() { - return remark; - } - - public void setRemark(String remark) { - this.remark = remark; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } - - public Date getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Date updateTime) { - this.updateTime = updateTime; - } - - public String getCreateBy() { - return createBy; - } - - public void setCreateBy(String createBy) { - this.createBy = createBy; - } - - public String getUpdateBy() { - return updateBy; - } - - public void setUpdateBy(String updateBy) { - this.updateBy = updateBy; - } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/CreditUnitMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/CreditUnitMapper.java new file mode 100644 index 000000000..1d39b3b01 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/CreditUnitMapper.java @@ -0,0 +1,10 @@ +package com.fuint.business.order.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.fuint.business.order.entity.CreditUnit; + +/** + * 挂账单位信息 mapper层 + */ +public interface CreditUnitMapper extends BaseMapper { +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/HangBillMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/HangBillMapper.java index 15cf53533..1b1555a36 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/HangBillMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/HangBillMapper.java @@ -1,10 +1,37 @@ package com.fuint.business.order.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.order.entity.HangBill; +import com.fuint.business.order.vo.HangBillVo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 挂账记录表 mapper层 */ public interface HangBillMapper extends BaseMapper { + /** + * 根据条件分页查询油品订单信息 + * @param page + * @param hangBill + * @return + */ + public IPage selectHangBillList(Page page,@Param("hangBill") HangBillVo hangBill); + + /** + * 查询所有挂账信息 + * @param storeId + * @return + */ + public List selectHangBills(@Param("storeId") int storeId); + + /** + * 根据id查询挂账信息 + * @param id + * @return + */ + public HangBillVo selectHangBillById(@Param("id") int id); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/HangBillMapper.xml b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/HangBillMapper.xml new file mode 100644 index 000000000..71e6a4a86 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/mapper/xml/HangBillMapper.xml @@ -0,0 +1,53 @@ + + + + + select hb.*,ms.real_name,ms.mobile,cu.unit_name,cu.person_credit,cu.contact_mobile + from hang_bill hb + inner join mt_staff ms on hb.staff_id = ms.id + inner join credit_unit cu on hb.credit_unit_id = cu.id + + + + + + \ No newline at end of file diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/CreditUnitService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/CreditUnitService.java new file mode 100644 index 000000000..cce47c2d6 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/CreditUnitService.java @@ -0,0 +1,24 @@ +package com.fuint.business.order.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.fuint.business.order.entity.CreditUnit; + +import java.util.List; + +/** + * 挂账单位信息 业务层 + */ +public interface CreditUnitService extends IService { + /** + * 查询所有挂账单位信息 + * @return + */ + public List selectCreditUnitList(); + + /** + * 添加挂账单位信息 + * @param creditUnit + * @return + */ + public int insertCreditUnit(CreditUnit creditUnit); +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/HangBillService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/HangBillService.java index cbf3a5217..0de3a7ebd 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/HangBillService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/HangBillService.java @@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.fuint.business.order.entity.HangBill; +import com.fuint.business.order.vo.HangBillVo; + +import java.util.List; +import java.util.Map; /** * 挂账记录信息 业务层 @@ -15,7 +19,27 @@ public interface HangBillService extends IService { * @param hangBill * @return */ - public IPage selectHangBillList(Page page, HangBill hangBill); + public IPage selectHangBillList(Page page, HangBillVo hangBill); + + /** + * 查询所有挂账记录信息 + * @return + */ + public List selectHangBills(); + + /** + * 根据id查询挂账信息 + * @param id + * @return + */ + public HangBillVo selectHangBillById(int id); + + /** + * 根据订单号查询挂账信息 + * @param orderNo + * @return + */ + public HangBill selectHangBillByOrderNo(String orderNo); /** * 添加挂账记录 @@ -23,4 +47,19 @@ public interface HangBillService extends IService { * @return */ public int insertHangBill(HangBill hangBill); + + /** + * 修改挂账记录 并收款 + * @param map + * @return + */ + public int updateHangBill(Map map); + + /** + * 修改挂账信息 + * @param hangBill + * @param repaidAmount + * @return + */ + public int updateHangBills(HangBill hangBill,Double repaidAmount); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/CreditUnitServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/CreditUnitServiceImpl.java new file mode 100644 index 000000000..49d496742 --- /dev/null +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/CreditUnitServiceImpl.java @@ -0,0 +1,27 @@ +package com.fuint.business.order.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.business.order.entity.CreditUnit; +import com.fuint.business.order.mapper.CreditUnitMapper; +import com.fuint.business.order.service.CreditUnitService; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class CreditUnitServiceImpl extends ServiceImpl implements CreditUnitService { + @Override + public List selectCreditUnitList() { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("status","qy"); + List list = baseMapper.selectList(queryWrapper); + return list; + } + + @Override + public int insertCreditUnit(CreditUnit creditUnit) { + int row = baseMapper.insert(creditUnit); + return row; + } +} diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HangBillServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HangBillServiceImpl.java index 4c5181dc9..f8c724d9a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HangBillServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/HangBillServiceImpl.java @@ -1,31 +1,165 @@ package com.fuint.business.order.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.fuint.api.fuyou.entity.MerchantConfig; +import com.fuint.api.fuyou.service.FyPayService; +import com.fuint.api.fuyou.service.MerchantConfigService; +import com.fuint.api.fuyou.service.OilConfigService; import com.fuint.business.order.entity.HangBill; import com.fuint.business.order.mapper.HangBillMapper; import com.fuint.business.order.service.HangBillService; +import com.fuint.business.order.vo.HangBillVo; import com.fuint.common.dto.AccountInfo; import com.fuint.common.util.TokenUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.SimpleDateFormat; +import java.util.*; + /** * 挂账记录信息 业务层 */ @Service public class HangBillServiceImpl extends ServiceImpl implements HangBillService { @Override - public IPage selectHangBillList(Page page, HangBill hangBill) { + public IPage selectHangBillList(Page page, HangBillVo hangBill) { AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); Integer storeId = nowAccountInfo.getStoreId(); hangBill.setStoreId(storeId); - return null; + IPage hangBillVoIPage = baseMapper.selectHangBillList(page, hangBill); + return hangBillVoIPage; + } + + @Override + public List selectHangBills() { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer storeId = nowAccountInfo.getStoreId(); + List hangBillVos = baseMapper.selectHangBills(storeId); + return hangBillVos; + } + + @Override + public HangBillVo selectHangBillById(int id) { + HangBillVo hangBillVo = baseMapper.selectHangBillById(id); + return hangBillVo; + } + + @Override + public HangBill selectHangBillByOrderNo(String orderNo) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("order_no",orderNo); + HangBill hangBill = baseMapper.selectOne(queryWrapper); + return hangBill; } @Override public int insertHangBill(HangBill hangBill) { + AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo(); + Integer storeId = nowAccountInfo.getStoreId(); + hangBill.setStoreId(storeId); +// 根据日期生成订单号 + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + String timestamp = dateFormat.format(new Date()); + String randomString = UUID.randomUUID().toString().replace("-","").substring(0,6); + String orderNo = timestamp+randomString; + Integer staffId = nowAccountInfo.getStaffId(); + hangBill.setStaffId(staffId); + hangBill.setOrderNo(orderNo); + hangBill.setOutstandAmount(hangBill.getAmount()); + hangBill.setRepaidAmount(0.0); int row = baseMapper.insert(hangBill); return row; } + + @Autowired + private FyPayService fyPayService; + @Autowired + private MerchantConfigService merchantConfigService; + @Autowired + private OilConfigService oilConfigService; + + @Override + public int updateHangBill(Map map) { + String payType = map.get("payType"); + if (!map.get("repaidAmount").equals("0") && !payType.equals("CASH")){ + Integer allAmount = (int) (Double.valueOf(map.get("repaidAmount"))*100); +// 判断是否开启支付规则 + List list = merchantConfigService.selectMeChByIsOpen(); + if (list.size()>0){ + oilConfigService.oilRule(); + } + // 根据店铺id查询商户配置信息 + MerchantConfig merchantConfig = merchantConfigService.selectMeChByIsUse("1"); + // 处理支付需要的数据 + Map map1 = new HashMap<>(); + map1.put("authCode",map.get("authCode")); + map1.put("allAmount",allAmount.toString()); + map1.put("orderNo",map.get("orderNo")); + map1.put("payType",payType); + map1.put("insCd",merchantConfig.getInsCd()); + map1.put("mchntCd",merchantConfig.getMchntCd()); + map1.put("goodsDes",merchantConfig.getMerchantName()); + map1.put("publicKey",merchantConfig.getPublicKey()); + map1.put("privateKey",merchantConfig.getPrivateKey()); + try { + fyPayService.pay(map); + }catch (Exception e){ + e.printStackTrace(); + } + } +// 根据id查询挂账信息 + HangBill hangBill = baseMapper.selectById(Integer.parseInt(map.get("id"))); + if (payType.equals("CASH")){ + hangBill.setPayStatus("paid"); + } + int row = 0; + hangBill.setRemark(map.get("remark")); +// 支付成功后修改挂账信息 + if (hangBill.getPayStatus().equals("paid")){ + Double repaidAmount1 = Double.valueOf(map.get("repaidAmount")); + Double amount = hangBill.getAmount(); + Double repaidAmount = hangBill.getRepaidAmount(); + Double outstandAmount = hangBill.getOutstandAmount(); + Double repaidAmountAfter = repaidAmount+repaidAmount1; +// 修改挂账信息 + hangBill.setRepaidAmount(repaidAmountAfter); + hangBill.setOutstandAmount(amount-repaidAmountAfter); + if (outstandAmount == repaidAmountAfter){ + hangBill.setStatus("1"); + hangBill.setReturnType("1"); + }else { + hangBill.setStatus("2"); + } + } + row = baseMapper.updateById(hangBill); + return row; + } + + @Override + public int updateHangBills(HangBill hangBill, Double repaidAmount) { + HangBill hangBill1 = this.updateStatus(hangBill, repaidAmount); + int row = baseMapper.updateById(hangBill1); + return row; + } + + private HangBill updateStatus(HangBill hangBill,Double repaidAmount1){ + Double amount = hangBill.getAmount(); + Double repaidAmount = hangBill.getRepaidAmount(); + Double outstandAmount = hangBill.getOutstandAmount(); + Double repaidAmountAfter = repaidAmount+repaidAmount1; +// 修改挂账信息 + hangBill.setRepaidAmount(repaidAmountAfter); + hangBill.setOutstandAmount(amount-repaidAmountAfter); + if (outstandAmount == repaidAmountAfter){ + hangBill.setStatus("1"); + hangBill.setReturnType("1"); + }else { + hangBill.setStatus("2"); + } + return hangBill; + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/HangBillVo.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/HangBillVo.java index d6b8393fc..59dd51789 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/HangBillVo.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/vo/HangBillVo.java @@ -5,4 +5,14 @@ import lombok.Data; @Data public class HangBillVo extends HangBill { +// 操作人名称 + private String realName; +// 操作人手机号 + private String mobile; +// 单位名称 + private String unitName; +// 挂账人 + private String personCredit; +// 联系电话 + private String contactMobile; } diff --git a/fuintCashierWeb/src/api/cashier/creditunit.js b/fuintCashierWeb/src/api/cashier/creditunit.js new file mode 100644 index 000000000..f4c8a1dd7 --- /dev/null +++ b/fuintCashierWeb/src/api/cashier/creditunit.js @@ -0,0 +1,19 @@ +import request from '@/utils/request' + +// 查询挂账信息列表 +export function listCreditUnit(query) { + return request({ + url: '/business/creditUnit/list', + method: 'get', + params: query + }) +} + +// 新增挂账记录 +export function addCreditUnit(data) { + return request({ + url: '/business/creditUnit', + method: 'post', + data: data + }) +} diff --git a/fuintCashierWeb/src/api/cashier/hangbill.js b/fuintCashierWeb/src/api/cashier/hangbill.js new file mode 100644 index 000000000..a23d5b4ea --- /dev/null +++ b/fuintCashierWeb/src/api/cashier/hangbill.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询挂账信息列表 +export function listHangBill(query) { + return request({ + url: '/business/hangBill/list', + method: 'get', + params: query + }) +} + +// 查询挂账信息列表 +export function hangBillInfo(id) { + return request({ + url: '/business/hangBill/'+id, + method: 'get', + }) +} + +// 查询所有挂账信息列表 +export function hangBills() { + return request({ + url: '/business/hangBill/hangBills', + method: 'get', + }) +} + +// 新增挂账记录 +export function addHangBill(data) { + return request({ + url: '/business/hangBill', + method: 'post', + data: data + }) +} + +// 修改挂账记录及收款 +export function editHangBill(data) { + return request({ + url: '/business/hangBill', + method: 'put', + data: data + }) +} diff --git a/fuintCashierWeb/src/views/cashier/NewComponents/credit.vue b/fuintCashierWeb/src/views/cashier/NewComponents/credit.vue index bca53f2f6..542cb6762 100644 --- a/fuintCashierWeb/src/views/cashier/NewComponents/credit.vue +++ b/fuintCashierWeb/src/views/cashier/NewComponents/credit.vue @@ -1,210 +1,833 @@