|
@@ -5,6 +5,8 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.caimei.mapper.LoginMapper;
|
|
import com.caimei.mapper.LoginMapper;
|
|
import com.caimei.model.ResponseJson;
|
|
import com.caimei.model.ResponseJson;
|
|
import com.caimei.model.dto.BuyerUserDto;
|
|
import com.caimei.model.dto.BuyerUserDto;
|
|
|
|
+import com.caimei.model.po.CmMallOrganizePo;
|
|
|
|
+import com.caimei.model.po.CmOrganizeBuyerPo;
|
|
import com.caimei.model.vo.BuyerUserVo;
|
|
import com.caimei.model.vo.BuyerUserVo;
|
|
import com.caimei.service.LoginService;
|
|
import com.caimei.service.LoginService;
|
|
import com.caimei.util.HttpRequest;
|
|
import com.caimei.util.HttpRequest;
|
|
@@ -14,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -71,11 +74,58 @@ public class LoginServiceImpl implements LoginService {
|
|
buyerUser.setOpenid(openid);
|
|
buyerUser.setOpenid(openid);
|
|
return ResponseJson.error("未绑定微信", buyerUser);
|
|
return ResponseJson.error("未绑定微信", buyerUser);
|
|
}
|
|
}
|
|
|
|
+ getOrderCount(buyerUser);
|
|
return ResponseJson.success(buyerUser);
|
|
return ResponseJson.success(buyerUser);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public ResponseJson<BuyerUserVo> invitationCode(BuyerUserDto buyerUserDto) {
|
|
public ResponseJson<BuyerUserVo> invitationCode(BuyerUserDto buyerUserDto) {
|
|
- return null;
|
|
|
|
|
|
+ CmOrganizeBuyerPo organizeBuyer = loginMapper.findByInvitationCode(buyerUserDto.getInvitationCode());
|
|
|
|
+ if (organizeBuyer == null) {
|
|
|
|
+ return ResponseJson.error("邀请码错误,请联系采美客服获取最新邀请码", null);
|
|
|
|
+ }
|
|
|
|
+ if ("2".equals(organizeBuyer.getStatus())) {
|
|
|
|
+ return ResponseJson.error("邀请码已被使用,请联系采美客服获取最新邀请码", null);
|
|
|
|
+ }
|
|
|
|
+ if (organizeBuyer.getInvitationCodeTime().compareTo(new Date()) < 0) {
|
|
|
|
+ return ResponseJson.error("邀请码已失效,请联系采美客服获取最新邀请码", null);
|
|
|
|
+ }
|
|
|
|
+ CmMallOrganizePo organize = loginMapper.findOrganize(organizeBuyer.getOrganizeId());
|
|
|
|
+ if (organize == null) {
|
|
|
|
+ return ResponseJson.error("您所属公司已下线,暂不能登录。请联系采美客服了解详情", null);
|
|
|
|
+ }
|
|
|
|
+ loginMapper.updateBuyer(buyerUserDto);
|
|
|
|
+ BuyerUserVo buyerUser = new BuyerUserVo();
|
|
|
|
+ getOrderCount(buyerUser);
|
|
|
|
+ buyerUser.setOrganizeId(organize.getId());
|
|
|
|
+ buyerUser.setOrganizeName(organize.getOrganizeName());
|
|
|
|
+ buyerUser.setOpenid(buyerUser.getOpenid());
|
|
|
|
+ return ResponseJson.success(buyerUser);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 统计订单数量
|
|
|
|
+ */
|
|
|
|
+ private void getOrderCount(BuyerUserVo buyerUser) {
|
|
|
|
+ //待确认数量
|
|
|
|
+ Integer organizeId = buyerUser.getOrganizeId();
|
|
|
|
+ Integer confirmedCount = loginMapper.findOrderCount(organizeId, 0);
|
|
|
|
+ buyerUser.setConfirmedCount(confirmedCount);
|
|
|
|
+ //待付款数量
|
|
|
|
+ Integer paymentCount = loginMapper.findOrderCount(organizeId, 1);
|
|
|
|
+ paymentCount = paymentCount == null ? 0 : paymentCount;
|
|
|
|
+ buyerUser.setPaymentCount(paymentCount);
|
|
|
|
+ //待发货数量
|
|
|
|
+ Integer waitShipmentsCount = loginMapper.findOrderCount(organizeId, 2);
|
|
|
|
+ waitShipmentsCount = waitShipmentsCount == null ? 0 : waitShipmentsCount;
|
|
|
|
+ buyerUser.setWaitShipmentsCount(waitShipmentsCount);
|
|
|
|
+ //已发货数量
|
|
|
|
+ Integer shipmentsCount = loginMapper.findOrderCount(organizeId, 3);
|
|
|
|
+ shipmentsCount = shipmentsCount == null ? 0 : shipmentsCount;
|
|
|
|
+ buyerUser.setShipmentsCount(shipmentsCount);
|
|
|
|
+ //退货款数量
|
|
|
|
+ Integer salesReturnCount = loginMapper.findOrderCount(organizeId, 4);
|
|
|
|
+ salesReturnCount = salesReturnCount == null ? 0 : salesReturnCount;
|
|
|
|
+ buyerUser.setSalesReturnCount(salesReturnCount);
|
|
}
|
|
}
|
|
}
|
|
}
|