Authored by Lixiaodi

修改记账分总账分账

package com.yohoufo.dal.order;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yohoufo.dal.order.model.SellerWalletDetail;
public interface SellerWalletDetailMapper {
... ... @@ -14,4 +18,8 @@ public interface SellerWalletDetailMapper {
int updateByPrimaryKeySelective(SellerWalletDetail record);
int updateByPrimaryKey(SellerWalletDetail record);
int selectUserDetailCount(@Param("uid") Integer uid);
List<SellerWalletDetail> selectUserDetailCount(@Param("uid") Integer uid, @Param("start") Integer start, @Param("count") Integer count);
}
\ No newline at end of file
... ...
... ... @@ -65,6 +65,15 @@ public class SellerWalletDetail {
public int getValue() {
return value;
}
public static Type of(int value) {
for (Type t : values()) {
if (t.value == value) {
return t;
}
}
return null;
}
}
}
\ No newline at end of file
... ...
... ... @@ -180,4 +180,19 @@
is_set = #{isSet,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectUserDetailCount" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
count(*)
from seller_wallet_detail
where uid = #{uid,jdbcType=INTEGER} and is_batch = 0 and type in (1,31,32,33,61)
</select>
<select id="selectUserDetail" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from seller_wallet_detail
where uid = #{uid,jdbcType=INTEGER} and is_batch = 0 and type in (1,31,32,33,61) order by id desc limit #{start},#{count}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yohoufo.order.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.service.MerchantOrderPaymentService;
@RestController
public class MerchantController {
private final Logger LOG = LoggerFactory.getLogger(MerchantController.class);
@Autowired
MerchantOrderPaymentService service;
@RequestMapping(params = "method=ufo.merchant.account")
@ResponseBody
public ApiResponse getAccountInfo(@RequestParam("uid") int uid) {
LOG.info("getAccountInfo uid={}", uid);
return service.getMerchantWalletInfo(uid);
}
@RequestMapping(params = "method=ufo.merchant.accountDetail")
@ResponseBody
public ApiResponse getAccountDetailInfo(@RequestParam("uid") int uid,
@RequestParam(value = "page", required = false, defaultValue = "1") int page,
@RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
LOG.info("getAccountDetailInfo uid={}, page={}, limit={}", uid, page, limit);
return service.getMerchantWalletDetailInfo(uid, page, limit);
}
}
... ...
package com.yohoufo.order.service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.error.ServiceError;
... ... @@ -9,26 +21,26 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.utils.TimeUtils;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
import com.yohoufo.dal.order.OrdersPayMapper;
import com.yohoufo.dal.order.OrdersPayRefundMapper;
import com.yohoufo.dal.order.SellerWalletDetailMapper;
import com.yohoufo.dal.order.SellerWalletMapper;
import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
import com.yohoufo.dal.order.model.OrdersPay;
import com.yohoufo.dal.order.model.OrdersPayRefund;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.order.common.Payment;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.cache.CacheCleaner;
import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.impl.PaymentServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@Service
public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
... ... @@ -145,6 +157,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setType(SellerWalletDetail.Type.RE_CHARGE.getValue());
swd.setCreateTime(TimeUtils.getTimeStampSecond());
swd.setUpdateTime(0);
JSONObject att = new JSONObject();
att.put("payment", orderInfo.getPayment());
swd.setAttachValue(att.toJSONString());
logger.info("充值后,处理增加钱包明细,bean={}", swd);
sellerWalletDetailMapper.insert(swd);
logger.info("充值后,处理增加钱包明细成功,orderCode={}", orderInfo.getOrderCode());
... ... @@ -295,6 +310,56 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
return buildOrderInfo(buyerOrder);
}
public com.yohoufo.common.ApiResponse getMerchantWalletInfo(Integer uid) {
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
if (sw == null) {
return new com.yohoufo.common.ApiResponse(400, "钱包不存在", null);
}
if (sw.getStatus() == null || sw.getStatus() == 0) {
return new com.yohoufo.common.ApiResponse(400, "钱包不可用", null);
}
JSONObject result = new JSONObject();
result.put("all", sw.getAmount().add(sw.getLockAmount()));
result.put("used", sw.getLockAmount());
result.put("avail", sw.getAmount());
return new com.yohoufo.common.ApiResponse(200, "查询成功", result);
}
public com.yohoufo.common.ApiResponse getMerchantWalletDetailInfo(Integer uid, int page, int limit) {
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
if (sw == null) {
return new com.yohoufo.common.ApiResponse(400, "钱包不存在", null);
}
if (sw.getStatus() == null || sw.getStatus() == 0) {
return new com.yohoufo.common.ApiResponse(400, "钱包不可用", null);
}
int count = sellerWalletDetailMapper.selectUserDetailCount(uid);
PageResp<JSONObject> pageResp = new PageResp<>();
pageResp.setPage(page);
pageResp.setPageSize(limit);
pageResp.setTotal(count);
pageResp.setPagetotal((int) Math.ceil(count * 1.0 / limit));
if (count == 0) {
pageResp.setData(new ArrayList<>());
return new com.yohoufo.common.ApiResponse(200, "查询成功", pageResp);
} else {
List<SellerWalletDetail> resultList = sellerWalletDetailMapper.selectUserDetailCount(uid,
(page - 1) * limit, count);
List<JSONObject> array = new ArrayList<>();
pageResp.setData(array);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
for (SellerWalletDetail detail : resultList) {
JSONObject result = new JSONObject();
result.put("amount", detail.getAmount());
result.put("type", sw.getType());
result.put("info", SellerWalletDetail.Type.of(sw.getType()).getName());
result.put("time", sdf.format(new Date(1000L * detail.getCreateTime())));
array.add(result);
}
return new com.yohoufo.common.ApiResponse(200, "查询成功", pageResp);
}
}
// 支付保证金:总账修改
public SellerWallet useEarnest(Integer uid, BigDecimal money, String attach) {
return changeEarnest(uid, money, 0L, attach, SellerWalletDetail.Type.PUBLISH);
... ...