Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
f7cca0de02
|
|
@ -2,8 +2,8 @@ package com.ghy.web.controller.order;
|
||||||
|
|
||||||
import com.ghy.common.core.controller.BaseController;
|
import com.ghy.common.core.controller.BaseController;
|
||||||
import com.ghy.common.core.domain.AjaxResult;
|
import com.ghy.common.core.domain.AjaxResult;
|
||||||
|
import com.ghy.common.core.domain.entity.SysUser;
|
||||||
import com.ghy.common.enums.*;
|
import com.ghy.common.enums.*;
|
||||||
import com.ghy.common.utils.StringUtils;
|
|
||||||
import com.ghy.customer.domain.Customer;
|
import com.ghy.customer.domain.Customer;
|
||||||
import com.ghy.customer.domain.CustomerAddress;
|
import com.ghy.customer.domain.CustomerAddress;
|
||||||
import com.ghy.customer.service.CustomerAddressService;
|
import com.ghy.customer.service.CustomerAddressService;
|
||||||
|
|
@ -23,11 +23,9 @@ import com.ghy.order.service.*;
|
||||||
import com.ghy.payment.domain.FinancialChangeRecord;
|
import com.ghy.payment.domain.FinancialChangeRecord;
|
||||||
import com.ghy.payment.domain.FinancialDetail;
|
import com.ghy.payment.domain.FinancialDetail;
|
||||||
import com.ghy.payment.domain.FinancialMaster;
|
import com.ghy.payment.domain.FinancialMaster;
|
||||||
import com.ghy.payment.domain.OrderTimeoutRecord;
|
|
||||||
import com.ghy.payment.service.FinancialChangeRecordService;
|
import com.ghy.payment.service.FinancialChangeRecordService;
|
||||||
import com.ghy.payment.service.FinancialDetailService;
|
import com.ghy.payment.service.FinancialDetailService;
|
||||||
import com.ghy.payment.service.FinancialMasterService;
|
import com.ghy.payment.service.FinancialMasterService;
|
||||||
import com.ghy.payment.service.OrderFineRecordService;
|
|
||||||
import com.ghy.system.domain.SysArea;
|
import com.ghy.system.domain.SysArea;
|
||||||
import com.ghy.system.service.ISysAreaService;
|
import com.ghy.system.service.ISysAreaService;
|
||||||
import com.ghy.system.service.IWxMsgService;
|
import com.ghy.system.service.IWxMsgService;
|
||||||
|
|
@ -37,6 +35,7 @@ import com.ghy.worker.domain.WorkerCertification;
|
||||||
import com.ghy.worker.service.IWorkerCertificationService;
|
import com.ghy.worker.service.IWorkerCertificationService;
|
||||||
import com.ghy.worker.service.WorkerService;
|
import com.ghy.worker.service.WorkerService;
|
||||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.apache.commons.lang3.time.DateUtils;
|
import org.apache.commons.lang3.time.DateUtils;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
@ -70,6 +69,8 @@ public class OrderController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private CustomerService customerService;
|
private CustomerService customerService;
|
||||||
@Resource
|
@Resource
|
||||||
|
private CustomerAddressService customerAddressService;
|
||||||
|
@Resource
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
@Resource
|
@Resource
|
||||||
private DeptGoodsCategoryService deptGoodsCategoryService;
|
private DeptGoodsCategoryService deptGoodsCategoryService;
|
||||||
|
|
@ -92,8 +93,6 @@ public class OrderController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private ISysAreaService sysAreaService;
|
private ISysAreaService sysAreaService;
|
||||||
@Resource
|
@Resource
|
||||||
private OrderFineRecordService orderFineRecordService;
|
|
||||||
@Resource
|
|
||||||
private FinancialChangeRecordService financialChangeRecordService;
|
private FinancialChangeRecordService financialChangeRecordService;
|
||||||
@Resource
|
@Resource
|
||||||
private IWorkerCertificationService workerCertificationService;
|
private IWorkerCertificationService workerCertificationService;
|
||||||
|
|
@ -143,6 +142,34 @@ public class OrderController extends BaseController {
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AjaxResult sysOrder(@RequestBody SysOrderAssignRequest request) {
|
public AjaxResult sysOrder(@RequestBody SysOrderAssignRequest request) {
|
||||||
|
|
||||||
|
SysUser sysUser = getSysUser();
|
||||||
|
Long deptId = sysUser.getDeptId();
|
||||||
|
String loginName = sysUser.getLoginName();
|
||||||
|
Customer customer = customerService.selectByAccount("sys_" + loginName);
|
||||||
|
if (customer == null) {
|
||||||
|
customer = new Customer();
|
||||||
|
customer.setAccount("sys_" + loginName);
|
||||||
|
customer.setName("平台用户_" + loginName);
|
||||||
|
customerService.insertCustomer(customer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getProvinceId() == null || request.getCityId() == null || request.getCountryId() == null || StringUtils.isBlank(request.getAddress())) {
|
||||||
|
return AjaxResult.error("请填写地址");
|
||||||
|
}
|
||||||
|
CustomerAddress customerAddress = customerAddressService.selectByCustomerAndAddress(customer.getCustomerId(),
|
||||||
|
request.getProvinceId(), request.getCityId(), request.getCountryId(), request.getAddress());
|
||||||
|
if (customerAddress == null) {
|
||||||
|
customerAddress = new CustomerAddress();
|
||||||
|
customerAddress.setCustomerId(customer.getCustomerId());
|
||||||
|
customerAddress.setProvinceId(request.getProvinceId());
|
||||||
|
customerAddress.setCityId(request.getCityId());
|
||||||
|
customerAddress.setCountryId(request.getCountryId());
|
||||||
|
customerAddress.setAddress(request.getAddress());
|
||||||
|
customerAddress.setIsDefault(0);
|
||||||
|
customerAddressService.insertCustomerAddress(customerAddress);
|
||||||
|
}
|
||||||
|
|
||||||
request.setGoodsDeptCategoryId(request.getCategory4());
|
request.setGoodsDeptCategoryId(request.getCategory4());
|
||||||
List<Long> ids = new ArrayList<>();
|
List<Long> ids = new ArrayList<>();
|
||||||
ids.add(request.getCategory1());
|
ids.add(request.getCategory1());
|
||||||
|
|
@ -154,10 +181,9 @@ public class OrderController extends BaseController {
|
||||||
OrderTemplateGoods orderTemplateGoods = new OrderTemplateGoods();
|
OrderTemplateGoods orderTemplateGoods = new OrderTemplateGoods();
|
||||||
orderTemplateGoods.setGoodsName(request.getGoodsBrand() + " " + deptGoodsCategory.getGoodsCategoryName());
|
orderTemplateGoods.setGoodsName(request.getGoodsBrand() + " " + deptGoodsCategory.getGoodsCategoryName());
|
||||||
orderTemplateGoods.setDeptGoodsCategoryIds(ids);
|
orderTemplateGoods.setDeptGoodsCategoryIds(ids);
|
||||||
orderTemplateGoods.setDeptGoodsCategoryNames(Arrays.asList(orderTemplateGoods.getGoodsName()));
|
orderTemplateGoods.setDeptGoodsCategoryNames(Collections.singletonList(orderTemplateGoods.getGoodsName()));
|
||||||
request.setGoods(Arrays.asList(orderTemplateGoods));
|
request.setGoods(Collections.singletonList(orderTemplateGoods));
|
||||||
String goodsBrand = request.getGoodsBrand();
|
String goodsBrand = request.getGoodsBrand();
|
||||||
Long deptId = getSysUser().getDeptId();
|
|
||||||
List<OrderTemplateGoods> goodsList = request.getGoods();
|
List<OrderTemplateGoods> goodsList = request.getGoods();
|
||||||
// 订单总价 不能小于0
|
// 订单总价 不能小于0
|
||||||
BigDecimal orderPrice = BigDecimal.valueOf(request.getPrice()).max(BigDecimal.ZERO);
|
BigDecimal orderPrice = BigDecimal.valueOf(request.getPrice()).max(BigDecimal.ZERO);
|
||||||
|
|
@ -205,10 +231,10 @@ public class OrderController extends BaseController {
|
||||||
orderMaster.setCode(orderMasterService.createOrderCode());
|
orderMaster.setCode(orderMasterService.createOrderCode());
|
||||||
orderMaster.setOrderType(0);
|
orderMaster.setOrderType(0);
|
||||||
orderMaster.setOrderStatus(OrderStatus.RECEIVE.code());
|
orderMaster.setOrderStatus(OrderStatus.RECEIVE.code());
|
||||||
orderMaster.setAddressId(request.getAddressId());
|
orderMaster.setAddressId(customerAddress.getCustomerAddressId());
|
||||||
orderMaster.setPayStatus(PayStatus.WAIT_PAY.getCode());
|
orderMaster.setPayStatus(PayStatus.WAIT_PAY.getCode());
|
||||||
orderMaster.setCreateTime(new Date());
|
orderMaster.setCreateTime(new Date());
|
||||||
orderMaster.setWorkerId(goods.getWorkerId());
|
orderMaster.setCustomerId(customer.getCustomerId());
|
||||||
orderMaster.setGoodsId(goods.getGoodsId());
|
orderMaster.setGoodsId(goods.getGoodsId());
|
||||||
orderMasterService.insertOrderMaster(orderMaster);
|
orderMasterService.insertOrderMaster(orderMaster);
|
||||||
Assert.notNull(orderMaster.getId(), "OrderMaster.id is null!");
|
Assert.notNull(orderMaster.getId(), "OrderMaster.id is null!");
|
||||||
|
|
@ -406,7 +432,7 @@ public class OrderController extends BaseController {
|
||||||
public AjaxResult appOrder(@RequestBody AppOrderRequest appOrderRequest) throws ParseException {
|
public AjaxResult appOrder(@RequestBody AppOrderRequest appOrderRequest) throws ParseException {
|
||||||
// 校验用户信息
|
// 校验用户信息
|
||||||
Customer customer = customerService.selectByCustomerId(appOrderRequest.getCustomerId());
|
Customer customer = customerService.selectByCustomerId(appOrderRequest.getCustomerId());
|
||||||
if (StringUtils.isNull(customer)) {
|
if (customer == null) {
|
||||||
return AjaxResult.error("用户不存在!");
|
return AjaxResult.error("用户不存在!");
|
||||||
}
|
}
|
||||||
List<AppGoodsRequest> appGoodsList = appOrderRequest.getGoodsList();
|
List<AppGoodsRequest> appGoodsList = appOrderRequest.getGoodsList();
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ public class OrderGoodsController extends BaseController {
|
||||||
@GetMapping()
|
@GetMapping()
|
||||||
public String orderGoods(Long orderId, ModelMap mmap) {
|
public String orderGoods(Long orderId, ModelMap mmap) {
|
||||||
OrderMaster orderMaster = orderMasterService.selectById(orderId);
|
OrderMaster orderMaster = orderMasterService.selectById(orderId);
|
||||||
|
mmap.put("orderId", orderId);
|
||||||
mmap.put("orderMaster", orderMaster);
|
mmap.put("orderMaster", orderMaster);
|
||||||
return prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,8 @@ public class AdapaySyncTimer {
|
||||||
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
|
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
|
||||||
JSONObject drawCash = adapayService.drawCash(deptId, orderNo, "T1", avlBalance, memberId, "提现", null);
|
JSONObject drawCash = adapayService.drawCash(deptId, orderNo, "T1", avlBalance, memberId, "提现", null);
|
||||||
log.info("Worker[{},{}]提现结果: {}", workerBank.getWorkerId(), workerBank.getName(), drawCash.toJSONString());
|
log.info("Worker[{},{}]提现结果: {}", workerBank.getWorkerId(), workerBank.getName(), drawCash.toJSONString());
|
||||||
|
} else {
|
||||||
|
log.error("Worker[{},{}]查询账户余额失败: {}", workerBank.getWorkerId(), workerBank.getName(), accountBalance.toJSONString());
|
||||||
}
|
}
|
||||||
} catch (BaseAdaPayException e) {
|
} catch (BaseAdaPayException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
|
@ -101,6 +103,8 @@ public class AdapaySyncTimer {
|
||||||
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
|
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
|
||||||
JSONObject drawCash = adapayService.drawCash(deptId, orderNo, "T1", avlBalance, memberId, "提现", null);
|
JSONObject drawCash = adapayService.drawCash(deptId, orderNo, "T1", avlBalance, memberId, "提现", null);
|
||||||
log.info("Customer[{},{}]提现结果: {}", customer.getCustomerId(), customer.getName(), drawCash.toJSONString());
|
log.info("Customer[{},{}]提现结果: {}", customer.getCustomerId(), customer.getName(), drawCash.toJSONString());
|
||||||
|
} else {
|
||||||
|
log.error("Customer[{},{}]查询账户余额失败: {}", customer.getCustomerId(), customer.getName(), accountBalance.toJSONString());
|
||||||
}
|
}
|
||||||
} catch (BaseAdaPayException e) {
|
} catch (BaseAdaPayException e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
|
@ -108,6 +112,9 @@ public class AdapaySyncTimer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定时同步提现状态
|
||||||
|
*/
|
||||||
@Scheduled(fixedRate = 5 * 60 * 1000L)
|
@Scheduled(fixedRate = 5 * 60 * 1000L)
|
||||||
public void syncDrawCash() {
|
public void syncDrawCash() {
|
||||||
List<DrawCashRecord> records = drawCashRecordMapper.selectByStatus("pending");
|
List<DrawCashRecord> records = drawCashRecordMapper.selectByStatus("pending");
|
||||||
|
|
@ -147,7 +154,7 @@ public class AdapaySyncTimer {
|
||||||
// 更新提现记录表状态
|
// 更新提现记录表状态
|
||||||
drawCashRecordMapper.updateStatus(record.getId(), "succeeded");
|
drawCashRecordMapper.updateStatus(record.getId(), "succeeded");
|
||||||
// 更新子订单表状态
|
// 更新子订单表状态
|
||||||
orderDetailService.updateDrawCashStatus(record.getId(), 2, new Date());
|
orderDetailService.updateDrawCashStatus(record.getId(), 2, null, new Date());
|
||||||
break;
|
break;
|
||||||
// 提现失败
|
// 提现失败
|
||||||
case "F":
|
case "F":
|
||||||
|
|
@ -155,7 +162,7 @@ public class AdapaySyncTimer {
|
||||||
// 更新提现记录表状态
|
// 更新提现记录表状态
|
||||||
drawCashRecordMapper.updateStatus(record.getId(), "failed");
|
drawCashRecordMapper.updateStatus(record.getId(), "failed");
|
||||||
// 更新子订单表状态
|
// 更新子订单表状态
|
||||||
orderDetailService.updateDrawCashStatus(record.getId(), -1, null);
|
orderDetailService.updateDrawCashStatus(record.getId(), -1, null, null);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12 search-collapse">
|
<div class="col-sm-12 search-collapse">
|
||||||
<form id="order-goods-form">
|
<form id="order-goods-form">
|
||||||
<input type="hidden" id="orderId" name="orderId" th:value="${orderMaster.id}">
|
<!-- <input type="hidden" id="orderId" name="orderId" th:value="${orderMaster.id}">-->
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-12 select-table table-striped">
|
<div class="col-sm-12 select-table table-striped">
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
|
|
||||||
function queryOrderGoodsList() {
|
function queryOrderGoodsList() {
|
||||||
var options = {
|
var options = {
|
||||||
url: prefix + "/list",
|
url: prefix + "/list?orderDetailId=" + orderId,
|
||||||
modalName: "订单商品",
|
modalName: "订单商品",
|
||||||
search: false,
|
search: false,
|
||||||
showSearch: false,
|
showSearch: false,
|
||||||
|
|
|
||||||
|
|
@ -50,4 +50,9 @@ public interface CustomerAddressMapper {
|
||||||
*/
|
*/
|
||||||
int updateCustomerAddress(CustomerAddress customerAddress);
|
int updateCustomerAddress(CustomerAddress customerAddress);
|
||||||
|
|
||||||
|
CustomerAddress selectByCustomerAndAddress(@Param("customerId") Long customerId,
|
||||||
|
@Param("provinceId") Long provinceId,
|
||||||
|
@Param("cityId") Long cityId,
|
||||||
|
@Param("countryId") Long countryId,
|
||||||
|
@Param("address") String address);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,4 +63,5 @@ public interface CustomerMapper {
|
||||||
*/
|
*/
|
||||||
List<Customer> selectByIds(@Param("customerIds") Collection<Long> customerIds);
|
List<Customer> selectByIds(@Param("customerIds") Collection<Long> customerIds);
|
||||||
|
|
||||||
|
Customer selectByAccount(String account);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,6 @@ public interface CustomerAddressService {
|
||||||
* @return 修改成功条数
|
* @return 修改成功条数
|
||||||
*/
|
*/
|
||||||
int updateCustomerAddress(CustomerAddress customerAddress);
|
int updateCustomerAddress(CustomerAddress customerAddress);
|
||||||
|
|
||||||
|
CustomerAddress selectByCustomerAndAddress(Long customerId, Long provinceId, Long cityId, Long countryId, String address);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,4 +73,6 @@ public interface CustomerService {
|
||||||
* @return Customer
|
* @return Customer
|
||||||
*/
|
*/
|
||||||
List<Customer> selectByIds(Set<Long> customerIds);
|
List<Customer> selectByIds(Set<Long> customerIds);
|
||||||
|
|
||||||
|
Customer selectByAccount(String account);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,4 +60,9 @@ public class CustomerAddressServiceImpl implements CustomerAddressService {
|
||||||
public int updateCustomerAddress(CustomerAddress customerAddress) {
|
public int updateCustomerAddress(CustomerAddress customerAddress) {
|
||||||
return customerAddressMapper.updateCustomerAddress(customerAddress);
|
return customerAddressMapper.updateCustomerAddress(customerAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CustomerAddress selectByCustomerAndAddress(Long customerId, Long provinceId, Long cityId, Long countryId, String address) {
|
||||||
|
return customerAddressMapper.selectByCustomerAndAddress(customerId, provinceId, cityId, countryId, address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,4 +104,9 @@ public class CustomerServiceImpl implements CustomerService {
|
||||||
}
|
}
|
||||||
return customerMapper.selectByIds(customerIds);
|
return customerMapper.selectByIds(customerIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Customer selectByAccount(String account) {
|
||||||
|
return customerMapper.selectByAccount(account);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,15 @@
|
||||||
WHERE customer_address_id = #{customerAddressId}
|
WHERE customer_address_id = #{customerAddressId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByCustomerAndAddress" resultMap="CustomerAddressResult">
|
||||||
|
<include refid="selectCustomerAddress"/>
|
||||||
|
WHERE customer_id = #{customerId}
|
||||||
|
AND province_id = #{provinceId}
|
||||||
|
AND city_id = #{cityId}
|
||||||
|
AND country_id = #{countryId}
|
||||||
|
AND address = #{address}
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertCustomerAddress" parameterType="com.ghy.customer.domain.CustomerAddress" useGeneratedKeys="true" keyProperty="customerAddressId">
|
<insert id="insertCustomerAddress" parameterType="com.ghy.customer.domain.CustomerAddress" useGeneratedKeys="true" keyProperty="customerAddressId">
|
||||||
insert into customer_address(
|
insert into customer_address(
|
||||||
<if test="customerId != null and customerId != 0">customer_id,</if>
|
<if test="customerId != null and customerId != 0">customer_id,</if>
|
||||||
|
|
|
||||||
|
|
@ -146,4 +146,9 @@
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByAccount" resultMap="CustomerResult">
|
||||||
|
<include refid="selectCustomer" />
|
||||||
|
WHERE account = #{account}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -106,10 +106,12 @@ public interface OrderDetailMapper {
|
||||||
*
|
*
|
||||||
* @param drawCashId 发起提现后Adapay返回的对象ID
|
* @param drawCashId 发起提现后Adapay返回的对象ID
|
||||||
* @param drawCashStatus 提现状态见{@link OrderDetail#getDrawCashStatus()}
|
* @param drawCashStatus 提现状态见{@link OrderDetail#getDrawCashStatus()}
|
||||||
|
* @param drawCashTime 发起提现时间
|
||||||
* @param arrivalTime 提现到账时间
|
* @param arrivalTime 提现到账时间
|
||||||
* @return 1
|
* @return 1
|
||||||
*/
|
*/
|
||||||
int updateDrawCashStatus(@Param("drawCashId") String drawCashId, @Param("drawCashStatus") int drawCashStatus, @Param("arrivalTime") Date arrivalTime);
|
int updateDrawCashStatus(@Param("drawCashId") String drawCashId, @Param("drawCashStatus") int drawCashStatus,
|
||||||
|
@Param("drawCashTime") Date drawCashTime, @Param("arrivalTime") Date arrivalTime);
|
||||||
|
|
||||||
int deleteByMaster(Long masterId);
|
int deleteByMaster(Long masterId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,13 @@ public class SysOrderAssignRequest {
|
||||||
private Long addressId;
|
private Long addressId;
|
||||||
// 发布价格(限制整数)
|
// 发布价格(限制整数)
|
||||||
private Integer price;
|
private Integer price;
|
||||||
|
|
||||||
|
private Long provinceId;
|
||||||
|
|
||||||
|
private Long cityId;
|
||||||
|
|
||||||
|
private Long countryId;
|
||||||
|
|
||||||
|
// 详细地址
|
||||||
|
private String address;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,10 +143,11 @@ public interface OrderDetailService {
|
||||||
*
|
*
|
||||||
* @param drawCashId 发起提现后Adapay返回的对象ID
|
* @param drawCashId 发起提现后Adapay返回的对象ID
|
||||||
* @param drawCashStatus 提现状态见{@link OrderDetail#getDrawCashStatus()}
|
* @param drawCashStatus 提现状态见{@link OrderDetail#getDrawCashStatus()}
|
||||||
|
* @param drawCashTime 发起提现时间
|
||||||
* @param arrivalTime 提现到账时间
|
* @param arrivalTime 提现到账时间
|
||||||
* @return 1
|
* @return 1
|
||||||
*/
|
*/
|
||||||
int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date arrivalTime);
|
int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date drawCashTime, Date arrivalTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退款成功时 退款回调接口里会调用这个方法
|
* 退款成功时 退款回调接口里会调用这个方法
|
||||||
|
|
|
||||||
|
|
@ -746,8 +746,8 @@ public class OrderDetailServiceImpl implements OrderDetailService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date arrivalTime) {
|
public int updateDrawCashStatus(String drawCashId, int drawCashStatus, Date drawCashTime, Date arrivalTime) {
|
||||||
return orderDetailMapper.updateDrawCashStatus(drawCashId, drawCashStatus, arrivalTime);
|
return orderDetailMapper.updateDrawCashStatus(drawCashId, drawCashStatus, drawCashTime, arrivalTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -254,12 +254,14 @@ public class OrderMasterServiceImpl implements OrderMasterService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 大师傅的MemberId
|
||||||
|
String masterWorkerMemberId = AdapayUtils.getWorkerMemberId(orderMaster.getWorkerId(), orderMaster.getDeptId());
|
||||||
// 罚金分给平台账户
|
// 罚金分给平台账户
|
||||||
memberMap.merge("0", fineMoney, BigDecimal::add);
|
memberMap.merge("0", fineMoney, BigDecimal::add);
|
||||||
// 大师傅服务金额减去罚金后剩下的钱 如果小于等于0元 就不用分账给大师傅了
|
// 大师傅服务金额减去罚金后剩下的钱 如果小于等于0元 就不用分账给大师傅了
|
||||||
BigDecimal bigWorkerAmtSubtractFine = bigWorkerAmt.subtract(fineMoney);
|
BigDecimal bigWorkerAmtSubtractFine = bigWorkerAmt.subtract(fineMoney);
|
||||||
if (BigDecimal.ZERO.compareTo(bigWorkerAmtSubtractFine) < 0) {
|
if (BigDecimal.ZERO.compareTo(bigWorkerAmtSubtractFine) < 0) {
|
||||||
memberMap.put(AdapayUtils.getWorkerMemberId(orderMaster.getWorkerId(), orderMaster.getDeptId()), bigWorkerAmtSubtractFine);
|
memberMap.put(masterWorkerMemberId, bigWorkerAmtSubtractFine);
|
||||||
}
|
}
|
||||||
confirmAmt = confirmAmt.add(bigWorkerAmt);
|
confirmAmt = confirmAmt.add(bigWorkerAmt);
|
||||||
|
|
||||||
|
|
@ -307,7 +309,24 @@ public class OrderMasterServiceImpl implements OrderMasterService {
|
||||||
}
|
}
|
||||||
String amount = member.getAmount();
|
String amount = member.getAmount();
|
||||||
try {
|
try {
|
||||||
drawCash(orderMaster.getDeptId(), memberId, amount);
|
String drawCashId = drawCash(orderMaster.getDeptId(), memberId, amount);
|
||||||
|
|
||||||
|
// 判断是否为大师傅的提现
|
||||||
|
if (masterWorkerMemberId.equals(memberId)) {
|
||||||
|
// 给大师傅的子单设置提现状态和提现时间 丢到线程池里执行 避免影响原业务逻辑 2023/5/18
|
||||||
|
executor.execute(() -> {
|
||||||
|
for (OrderDetail orderDetail : orderDetails) {
|
||||||
|
if (orderMaster.getWorkerId().equals(orderDetail.getWorkerId())) {
|
||||||
|
OrderDetail odUpdate = new OrderDetail();
|
||||||
|
odUpdate.setId(orderDetail.getId());
|
||||||
|
odUpdate.setDrawCashTime(new Date());
|
||||||
|
odUpdate.setDrawCashStatus(1);
|
||||||
|
odUpdate.setDrawCashId(drawCashId);
|
||||||
|
orderDetailService.updateOrderDetail(odUpdate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (BaseAdaPayException e) {
|
} catch (BaseAdaPayException e) {
|
||||||
logger.error("自动发起提现失败: orderMasterId={}, memberId={}, cashAmt={}", orderMasterId, memberId, amount, e);
|
logger.error("自动发起提现失败: orderMasterId={}, memberId={}, cashAmt={}", orderMasterId, memberId, amount, e);
|
||||||
}
|
}
|
||||||
|
|
@ -321,15 +340,18 @@ public class OrderMasterServiceImpl implements OrderMasterService {
|
||||||
* @param memberId Adapay实名账户ID
|
* @param memberId Adapay实名账户ID
|
||||||
* @param amount 提现金额
|
* @param amount 提现金额
|
||||||
*/
|
*/
|
||||||
private void drawCash(Long deptId, String memberId, String amount) throws BaseAdaPayException {
|
private String drawCash(Long deptId, String memberId, String amount) throws BaseAdaPayException {
|
||||||
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
|
String orderNo = AdapayUtils.createOrderNo(AdapayOrderType.DRAW_CASH);
|
||||||
JSONObject response = adapayService.drawCash(deptId, orderNo, "T1", amount, memberId, "订单结算", null);
|
JSONObject response = adapayService.drawCash(deptId, orderNo, "T1", amount, memberId, "订单结算", null);
|
||||||
|
|
||||||
boolean status = AdapayStatusEnum.pending.code.equals(response.getString("status")) ||
|
boolean status = AdapayStatusEnum.pending.code.equals(response.getString("status")) ||
|
||||||
AdapayStatusEnum.succeeded.code.equals(response.getString("status"));
|
AdapayStatusEnum.succeeded.code.equals(response.getString("status"));
|
||||||
if (!status) {
|
if (status) {
|
||||||
|
return response.getString("id");
|
||||||
|
} else {
|
||||||
//如果提现失败 把信息记录到error日志里
|
//如果提现失败 把信息记录到error日志里
|
||||||
logger.error("提现失败: deptId={}, memberId={}, amount={}, 失败原因:{}", deptId, memberId, amount, response.getString("error_msg"));
|
logger.error("提现失败: deptId={}, memberId={}, amount={}, 失败原因:{}", deptId, memberId, amount, response.getString("error_msg"));
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -392,9 +392,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateDrawCashStatus">
|
<update id="updateDrawCashStatus">
|
||||||
UPDATE order_detail
|
UPDATE order_detail SET
|
||||||
SET draw_cash_status = #{drawCashStatus},
|
<if test="drawCashId != null">draw_cash_id = #{drawCashId},</if>
|
||||||
arrival_time = #{arrivalTime}
|
<if test="drawCashTime != null">draw_cash_time = #{drawCashTime},</if>
|
||||||
|
<if test="arrivalTime != null">arrival_time = #{arrivalTime},</if>
|
||||||
|
<if test="drawCashStatus != null">draw_cash_status = #{drawCashStatus},</if>
|
||||||
|
update_time = NOW()
|
||||||
WHERE draw_cash_id = #{drawCashId}
|
WHERE draw_cash_id = #{drawCashId}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,9 @@
|
||||||
<if test="orderId != null and orderId != 0">
|
<if test="orderId != null and orderId != 0">
|
||||||
AND order_id = #{orderId}
|
AND order_id = #{orderId}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="orderDetailId != null and orderDetailId != 0">
|
||||||
|
AND order_detail_id = #{orderDetailId}
|
||||||
|
</if>
|
||||||
<if test="goodsStandardId != null and goodsStandardId != 0">
|
<if test="goodsStandardId != null and goodsStandardId != 0">
|
||||||
AND goods_standard_id = #{goodsStandardId}
|
AND goods_standard_id = #{goodsStandardId}
|
||||||
</if>
|
</if>
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@
|
||||||
SELECT COUNT(*) FROM order_master om
|
SELECT COUNT(*) FROM order_master om
|
||||||
<where>
|
<where>
|
||||||
<if test="isMonitoredOrder">
|
<if test="isMonitoredOrder">
|
||||||
AND (om.all_self_assigned = 0 or om.all_self_assigned is not null) AND om.order_status in (1,2,3,4)
|
AND (om.all_self_assigned = 0 or om.all_self_assigned is null) AND om.order_status in (1,2,3,4)
|
||||||
</if>
|
</if>
|
||||||
<if test="deptId != null and deptId != 0">
|
<if test="deptId != null and deptId != 0">
|
||||||
AND om.dept_id = #{deptId}
|
AND om.dept_id = #{deptId}
|
||||||
|
|
|
||||||
|
|
@ -37,10 +37,10 @@ public interface SysUserMapper
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param loginName 用户名
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
public SysUser selectUserByLoginName(String userName);
|
public SysUser selectUserByLoginName(String loginName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过手机号码查询用户
|
* 通过手机号码查询用户
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,10 @@ public interface ISysUserService
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param loginName 用户名
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
public SysUser selectUserByLoginName(String userName);
|
public SysUser selectUserByLoginName(String loginName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过手机号码查询用户
|
* 通过手机号码查询用户
|
||||||
|
|
|
||||||
|
|
@ -105,13 +105,13 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
* @param userName 用户名
|
* @param loginName 用户名
|
||||||
* @return 用户对象信息
|
* @return 用户对象信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysUser selectUserByLoginName(String userName)
|
public SysUser selectUserByLoginName(String loginName)
|
||||||
{
|
{
|
||||||
return userMapper.selectUserByLoginName(userName);
|
return userMapper.selectUserByLoginName(loginName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue