package com.buy507.mall.portal;

import com.buy507.mall.mapper.UmsMemberMapper;
import com.buy507.mall.model.OmsOrder;
import com.buy507.mall.model.UmsMember;
import com.buy507.mall.portal.service.MemberCommissionService;
import com.buy507.mall.portal.service.OmsPortalOrderService;
import com.buy507.mall.portal.service.UmsMemberService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RunWith(SpringRunner.class)
@SpringBootTest
public class OmsPortalOrderServiceTest {

    @Autowired
    private OmsPortalOrderService portalOrderService;


    /**
     * 计算会员等级升级
     */
    @Resource
    private MemberCommissionService memberCommissionService;


    /**
     * 支付宝回调逻辑 测试
     */
    @Test
    public void alipayCallbackTest() {
        Map params = new HashMap<>();
        params.put("trade_status", "TRADE_SUCCESS");
        params.put("out_trade_no", "22123213");

        portalOrderService.alipayCallback(params);
    }



    @Autowired
    private UmsMemberService memberService;

    @Test
    public void getMemberInfoTest() {
        memberService.getMemberInfo();
    }

    @Test
    public void registerTest() {
        memberService.register("123213111www", "123sad", "dss", "S4ZG2D2D0JCS");
    }



    @Resource
    private UmsMemberMapper memberMapper;

    @Test
    public void MemberCommission(){
        UmsMember currentMember = memberMapper.selectByPrimaryKey(4L);
        memberCommissionService.computeCommission(currentMember);
    }

    @Test
    public void personalTeamTest(){
        memberService.personalTeam();
    }


}
